ci: rework workflow for Gitea Actions (M0.2) #2

Merged
sharang merged 3 commits from fix/m0.2-gitea-friendly-ci into main 2026-05-18 19:42:28 +00:00
2 changed files with 42 additions and 25 deletions
+41 -25
View File
@@ -1,4 +1,5 @@
# CI for Go services. Copy to .gitea/workflows/ci.yaml in the repo. # CI for Go services on Gitea Actions.
# `shared` always runs; `test` and `image` activate when go.sum lands.
name: ci name: ci
on: on:
@@ -16,32 +17,53 @@ jobs:
- name: commitlint (PR only) - name: commitlint (PR only)
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
uses: wagoid/commitlint-github-action@v6 shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
pattern='^(feat|fix|docs|chore|refactor|test|perf|build|ci|revert)(\([a-z0-9_/.-]+\))?!?: .{1,72}$'
bad=0
while IFS= read -r subject; do
if ! [[ "$subject" =~ $pattern ]]; then
echo "::error::Commit subject does not match Conventional Commits: $subject"
bad=$((bad+1))
fi
done < <(git log --format=%s "${BASE_SHA}..${HEAD_SHA}")
if [ "$bad" -gt 0 ]; then
echo "::error::$bad commit(s) failed commitlint."
exit 1
fi
echo "commitlint: OK"
- name: gitleaks - name: gitleaks
uses: gitleaks/gitleaks-action@v2 shell: bash
run: |
set -euo pipefail
GL_VERSION=8.18.4
curl -fsSL "https://github.com/gitleaks/gitleaks/releases/download/v${GL_VERSION}/gitleaks_${GL_VERSION}_linux_x64.tar.gz" \
| tar -xz -C /tmp gitleaks
/tmp/gitleaks detect --source . --no-banner --redact --verbose --exit-code 1
- name: trivy fs scan - name: trivy fs scan
uses: aquasecurity/trivy-action@master shell: bash
with: run: |
scan-type: fs set -euo pipefail
severity: HIGH,CRITICAL TRIVY_VERSION=0.70.0
exit-code: 1 curl -fsSL "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" \
| tar -xz -C /tmp trivy
/tmp/trivy fs --severity HIGH,CRITICAL --exit-code 1 --no-progress --skip-dirs node_modules,target,dist .
test: test:
runs-on: docker runs-on: docker
if: hashFiles('go.sum') != ''
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-go@v5 - uses: actions/setup-go@v5
with: { go-version: '1.22' } with: { go-version: '1.22' }
- name: cache
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('go.sum') }}
- name: fmt - name: fmt
run: test -z "$(gofmt -l .)" run: test -z "$(gofmt -l .)"
@@ -52,7 +74,7 @@ jobs:
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v6
with: { version: latest } with: { version: latest }
- name: test (with integration via testcontainers) - name: test
run: go test -race -coverprofile=cover.out ./... run: go test -race -coverprofile=cover.out ./...
- name: coverage gate - name: coverage gate
@@ -64,28 +86,25 @@ jobs:
image: image:
needs: [shared, test] needs: [shared, test]
if: github.event_name == 'push' && github.ref == 'refs/heads/main' if: github.event_name == 'push' && github.ref == 'refs/heads/main' && hashFiles('Dockerfile') != ''
runs-on: docker runs-on: docker
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: login to registry - uses: docker/login-action@v3
uses: docker/login-action@v3
with: with:
registry: registry.yourplatform.com registry: registry.yourplatform.com
username: ${{ secrets.REGISTRY_USER }} username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }} password: ${{ secrets.REGISTRY_PASS }}
- name: build + push - uses: docker/build-push-action@v6
uses: docker/build-push-action@v6
with: with:
push: true push: true
tags: | tags: |
registry.yourplatform.com/${{ github.event.repository.name }}:sha-${{ github.sha }} registry.yourplatform.com/${{ github.event.repository.name }}:sha-${{ github.sha }}
registry.yourplatform.com/${{ github.event.repository.name }}:env-stage registry.yourplatform.com/${{ github.event.repository.name }}:env-stage
- name: sbom - uses: anchore/sbom-action@v0
uses: anchore/sbom-action@v0
with: with:
image: registry.yourplatform.com/${{ github.event.repository.name }}:sha-${{ github.sha }} image: registry.yourplatform.com/${{ github.event.repository.name }}:sha-${{ github.sha }}
@@ -93,6 +112,3 @@ jobs:
run: orca apply --env=stage --image-tag=sha-${{ github.sha }} run: orca apply --env=stage --image-tag=sha-${{ github.sha }}
env: env:
ORCA_TOKEN: ${{ secrets.ORCA_STAGE_TOKEN }} ORCA_TOKEN: ${{ secrets.ORCA_STAGE_TOKEN }}
- name: e2e on stage
run: orca exec --env=stage e2e-runner
+1
View File
@@ -12,6 +12,7 @@ Generated section is appended on release tag via `git-cliff` (see `.gitea/workfl
- -
### Fixed ### Fixed
- ci: rework workflow for Gitea Actions (bash commitlint, inline gitleaks binary, per-stack jobs gated on real code)
- -
### Removed ### Removed