The marker records which object the publish is placing #11
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: build | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| # Alpine patch releases reach the image through this, since the Dockerfile pins | |
| # a minor tag rather than a patch. | |
| schedule: | |
| - cron: '0 4 * * 1' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| IMAGE: ghcr.io/runonflux/flux-volume-tools | |
| jobs: | |
| # flux-op's own logic, reachable without a container in the way. The shell | |
| # implementation this replaced could only be exercised through one, which is | |
| # how it shipped handing every command it ran /dev/null as its standard input. | |
| unit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Assert the source is formatted | |
| run: | | |
| unformatted="$(gofmt -l cmd)" | |
| if [ -n "$unformatted" ]; then | |
| echo "not gofmt'd: $unformatted" | |
| exit 1 | |
| fi | |
| - run: go vet ./... | |
| - run: go test ./... -race | |
| # What the image DOES, exercised through a container configured exactly as the | |
| # FluxOS volume executor configures it - read-only rootfs, no network, all | |
| # capabilities dropped but three, and the app volume as the only mount. A plain | |
| # `docker run` would pass while an operation that quietly depends on anything | |
| # else failed on a node. | |
| # | |
| # Both architectures. arm64 is published and, before this, was never executed | |
| # here at all. | |
| image: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: [linux/amd64, linux/arm64] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| # Only the non-native architecture needs emulation, and only to RUN the | |
| # image: flux-op is cross-compiled in the build stage either way. | |
| - uses: docker/setup-qemu-action@v3 | |
| if: matrix.platform != 'linux/amd64' | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Build the image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: ${{ matrix.platform }} | |
| push: false | |
| load: true | |
| tags: flux-volume-tools:test | |
| # -count=1 because the image is an input the test cache cannot see: with a | |
| # warm cache the arm64 run would report the amd64 result and pass without | |
| # ever starting a container. | |
| - name: Assert what the image does | |
| run: go test -tags docker -count=1 ./test/container/ -v | |
| publish: | |
| needs: [unit, image] | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE }} | |
| tags: | | |
| type=ref,event=tag | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| # This digest is the value FluxOS pins. It is the manifest LIST digest, so it | |
| # resolves to the right architecture on both x86 and arm nodes. | |
| - name: Publish digest to run summary | |
| run: | | |
| { | |
| echo '## Published' | |
| echo | |
| echo 'Pin this in FluxOS:' | |
| echo | |
| echo '```' | |
| echo "${{ env.IMAGE }}@${{ steps.build.outputs.digest }}" | |
| echo '```' | |
| } >> "$GITHUB_STEP_SUMMARY" |