name: CD on: push: branches: [main] tags: ["v*"] pull_request: branches: [main] env: IMAGE: __PROJECT_NAME__ jobs: guard: name: Detect unsubstituted template runs-on: self-hosted outputs: is_template: ${{ steps.detect.outputs.is_template }} steps: - uses: actions/checkout@v4 - id: detect run: | # Grep the PLACEHOLDER, never the value substitution writes. A guard # that greps its own substituted module path matches forever and # skips every job below it -- see harg-bygglov-go#8, where that cost # five weeks of empty green runs on a repo that never compiled. if grep -q '__MODULE_PATH__' go.mod; then echo "is_template=true" >> "$GITHUB_OUTPUT" else echo "is_template=false" >> "$GITHUB_OUTPUT" fi check: name: Lint / Test / Vet needs: guard if: needs.guard.outputs.is_template != 'true' runs-on: self-hosted steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: go-version-file: go.mod cache: false - name: Install toolchain run: | go version go install github.com/a-h/templ/cmd/templ@latest curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh \ | sh -s -- -b "$(go env GOPATH)/bin" v2.11.4 - name: Run checks run: task check build: name: Build & Import needs: [guard, check] if: needs.guard.outputs.is_template != 'true' && github.event_name != 'pull_request' runs-on: self-hosted outputs: image-tag: ${{ steps.meta.outputs.sha-tag }} steps: - uses: actions/checkout@v4 - name: Derive image tags id: meta run: | SHA=$(git rev-parse --short HEAD) echo "sha-tag=${SHA}" >> "$GITHUB_OUTPUT" # infra#309: the implementation lives in .gitea/build-image.sh, a # byte-identical copy of mathias/infra's ci-templates/build-image.sh. # Do not edit it here -- edit the canonical file, run `task ci:sync`, # and infra's drift gate will name any repo still carrying an old copy. # # This matters more in a template than anywhere else: every repo # generated from here inherits its CI, so a template that carries the # build LOGIC manufactures a new copy of every bug in it. That is # precisely how rootless buildah (infra#241) reached a dozen repos, and # why the fix then had to be rediscovered here weeks later. A template # that carries a CALL manufactures nothing. # # NEW REPOS: add yourself to mathias/infra's ci-templates/adopters.txt so # the gate keeps this copy current. Until you do, the copy is unmanaged # and will silently fall behind. # # `bash