|
1 | 1 | name: build-push |
| 2 | + |
2 | 3 | on: |
| 4 | + workflow_call: |
| 5 | + secrets: |
| 6 | + GCLOUD_OIDC_POOL: |
| 7 | + required: false |
| 8 | + GSA: |
| 9 | + required: false |
| 10 | + pull_request: |
3 | 11 | push: |
| 12 | + branches: |
| 13 | + - main |
4 | 14 | workflow_dispatch: |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
5 | 19 | jobs: |
6 | 20 | test: |
7 | | - permissions: |
8 | | - contents: read |
9 | 21 | runs-on: ubuntu-24.04 |
10 | 22 | steps: |
11 | 23 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 |
| 24 | + with: |
| 25 | + persist-credentials: false |
| 26 | + |
| 27 | + - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6 |
| 28 | + with: |
| 29 | + go-version-file: go.mod |
| 30 | + |
| 31 | + - name: Verify dependencies |
| 32 | + run: | |
| 33 | + go mod download |
| 34 | + go mod verify |
| 35 | + go mod tidy -diff |
| 36 | +
|
| 37 | + - name: Check GoReleaser configuration |
| 38 | + uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7 |
| 39 | + with: |
| 40 | + distribution: goreleaser |
| 41 | + version: v2.17.0 |
| 42 | + args: check |
| 43 | + |
| 44 | + - name: Lint |
| 45 | + uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9 |
| 46 | + with: |
| 47 | + version: v2.12.2 |
12 | 48 |
|
13 | | - - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6 |
| 49 | + - name: Test |
| 50 | + run: go test -race ./... |
| 51 | + |
| 52 | + image-check: |
| 53 | + if: github.event_name == 'pull_request' |
| 54 | + strategy: |
| 55 | + fail-fast: false |
| 56 | + matrix: |
| 57 | + runner: |
| 58 | + - ubuntu-24.04 |
| 59 | + - ubuntu-24.04-arm |
| 60 | + runs-on: ${{ matrix.runner }} |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 |
14 | 63 | with: |
15 | | - go-version: ">=1.25.3" |
| 64 | + persist-credentials: false |
| 65 | + |
| 66 | + - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3 |
16 | 67 |
|
17 | | - - uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9 |
| 68 | + - name: Resolve native platform |
| 69 | + id: platform |
| 70 | + run: | |
| 71 | + set -euo pipefail |
| 72 | + case "$RUNNER_ARCH" in |
| 73 | + X64) platform=amd64 ;; |
| 74 | + ARM64) platform=arm64 ;; |
| 75 | + *) echo "Unsupported runner architecture: $RUNNER_ARCH" >&2; exit 1 ;; |
| 76 | + esac |
| 77 | + echo "name=$platform" >> "$GITHUB_OUTPUT" |
18 | 78 |
|
19 | | - - name: Test with the Go CLI |
20 | | - run: go test -v -race ./... |
| 79 | + - name: Build native image without credentials |
| 80 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6 |
| 81 | + with: |
| 82 | + context: . |
| 83 | + load: true |
| 84 | + platforms: linux/${{ steps.platform.outputs.name }} |
| 85 | + provenance: false |
| 86 | + push: false |
| 87 | + tags: vault-init:ci-${{ steps.platform.outputs.name }} |
| 88 | + |
| 89 | + - name: Scan native image |
| 90 | + uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0 |
| 91 | + with: |
| 92 | + image-ref: vault-init:ci-${{ steps.platform.outputs.name }} |
| 93 | + format: table |
| 94 | + exit-code: "1" |
| 95 | + ignore-unfixed: true |
| 96 | + severity: HIGH,CRITICAL |
| 97 | + vuln-type: os,library |
21 | 98 |
|
22 | | - build-push: |
23 | | - needs: [test] |
24 | | - uses: libops/.github/.github/workflows/build-push.yaml@main |
| 99 | + publish: |
| 100 | + if: github.event_name != 'pull_request' |
| 101 | + needs: test |
| 102 | + uses: libops/.github/.github/workflows/build-push.yaml@578137212ead4ab4059e95df17fa30e9b7ac4aed |
25 | 103 | with: |
26 | | - docker-registry: "libops" |
| 104 | + ref: ${{ github.sha }} |
| 105 | + expected-main-sha: ${{ github.ref == 'refs/heads/main' && github.sha || '' }} |
| 106 | + additional-gar-registry: us-docker.pkg.dev/libops-images/public |
| 107 | + scan: true |
| 108 | + sign: true |
| 109 | + certificate-identity: https://github.com/libops/.github/.github/workflows/build-push.yaml@578137212ead4ab4059e95df17fa30e9b7ac4aed |
27 | 110 | permissions: |
28 | 111 | contents: read |
| 112 | + id-token: write |
29 | 113 | packages: write |
30 | | - secrets: inherit |
| 114 | + secrets: |
| 115 | + GCLOUD_OIDC_POOL: ${{ secrets.GCLOUD_OIDC_POOL }} |
| 116 | + GSA: ${{ secrets.GSA }} |
0 commit comments