CI #583
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| concurrency: | |
| group: ci-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - release/* | |
| tags: | |
| - "v*" | |
| pull_request: | |
| schedule: | |
| - cron: "0 10 * * *" # ~2am PST | |
| workflow_dispatch: | |
| inputs: | |
| debug_enabled: | |
| type: boolean | |
| description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)" | |
| required: false | |
| default: false | |
| env: | |
| REGISTRY: ghcr.io | |
| ORG: githedgehog | |
| jobs: | |
| test: | |
| runs-on: lab | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| cache: true | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lint and generate code | |
| run: | | |
| just --timestamp lint-gha gen _lint | |
| - name: Some Go lint | |
| run: | | |
| just --timestamp _lint | |
| - name: More Go lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| # keep in sync with hack/tools.just | |
| version: v1.64.8 | |
| install-mode: goinstall | |
| - name: Build and run tests | |
| run: | | |
| just --timestamp build test | |
| - name: Go mod tidy | |
| run: | | |
| go mod tidy | |
| go mod vendor | |
| # Don't remove it! We shouldn't allow CI to pass if there are any changes not committed after running gen/lint/test | |
| - name: Fail on dirty | |
| run: | | |
| if ! git status --short || ! git diff --quiet; then | |
| git --no-pager diff -- . :^vendor | |
| echo "::error::Working directory is dirty. Please run 'just gen lint && go mod tidy && go mod vendor' and commit the changes." | |
| exit 1 | |
| fi | |
| - name: Setup tmate session for debug | |
| if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
| uses: mxschmitt/action-tmate@v3 | |
| timeout-minutes: 30 | |
| with: | |
| limit-access-to-actor: true | |
| publish: | |
| runs-on: lab | |
| if: startsWith(github.event.ref, 'refs/tags/v') && github.event_name == 'push' | |
| needs: | |
| - test | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| cache: true | |
| - name: Login to ghcr.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish Images, Helm charts and Bins on release | |
| run: | | |
| just --timestamp oci_repo=ghcr.io push |