| name: go |
| |
| on: |
| push: |
| branches: |
| - main |
| pull_request: |
| workflow_dispatch: |
| |
| permissions: |
| contents: read |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.ref }} |
| cancel-in-progress: true |
| |
| jobs: |
| tidy: |
| name: go build and go mod tidy |
| runs-on: ubuntu-latest |
| steps: |
| - name: Harden Runner |
| uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2 |
| with: |
| egress-policy: audit |
| |
| - name: Checkout |
| uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 |
| |
| - name: Set up Bazel |
| uses: bazel-contrib/setup-bazel@c5acdfb288317d0b5c0bbd7a396a3dc868bb0f86 # 0.19.0 |
| with: |
| bazelisk-cache: true |
| repository-cache: true |
| |
| - name: Run go mod tidy |
| run: bazel run @io_bazel_rules_go//go -- mod tidy |
| |
| - name: Run go build |
| run: bazel run @io_bazel_rules_go//go -- build ./... |
| |
| - name: Check for changes |
| run: | |
| if ! git diff --exit-code -- go.mod go.sum MODULE.bazel; then |
| echo "::error::go.mod, go.sum or MODULE.bazel is out of date. Run 'bazel run @io_bazel_rules_go//go -- mod tidy' and commit the result." |
| exit 1 |
| fi |