name: Build on: push: branches: - main pull_request: branches: - main permissions: packages: write jobs: build: name: Build runs-on: ubuntu-latest permissions: id-token: write attestations: write packages: write contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v5 - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 - uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0 - uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - id: vars run: make ci--env - id: image-tag run: | if [[ "${{ github.event_name }}" == "pull_request" ]]; then echo "tags<> $GITHUB_OUTPUT echo "ghcr.io/beryju/gravity:pr-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT else echo "tags<> $GITHUB_OUTPUT echo "ghcr.io/beryju/gravity:latest" >> $GITHUB_OUTPUT echo "ghcr.io/beryju/gravity:${{ steps.vars.outputs.sha }}" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi - id: meta uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: flavor: | latest=true tags: | type=raw,value=${{ steps.vars.outputs.sha }} - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 id: push with: tags: ${{ steps.image-tag.outputs.tags }} push: true platforms: linux/amd64,linux/arm64 sbom: true provenance: true context: . build-args: | BUILD=${{ steps.vars.outputs.build }} GIT_BUILD_HASH=${{ steps.vars.outputs.sha }} labels: ${{ steps.meta.outputs.labels }} - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v3 if: ${{ github.ref == 'refs/heads/main' }} with: subject-name: ghcr.io/beryju/gravity subject-digest: ${{ steps.push.outputs.digest }} push-to-registry: true build-debug: name: Build (debug) runs-on: ubuntu-latest permissions: id-token: write attestations: write packages: write contents: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v5 - uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0 - uses: docker/setup-buildx-action@594f3bf4285d9ea8dc53c9a0c9c4092420091003 # v4.4.0 - uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - id: vars run: make ci--env - id: image-tag run: | if [[ "${{ github.event_name }}" == "pull_request" ]]; then echo "tags<> $GITHUB_OUTPUT echo "ghcr.io/beryju/gravity:pr-${{ github.event.pull_request.number }}-debug" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT else echo "tags<> $GITHUB_OUTPUT echo "ghcr.io/beryju/gravity:latest-debug" >> $GITHUB_OUTPUT echo "ghcr.io/beryju/gravity:${{ steps.vars.outputs.sha }}-debug" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi - id: meta uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 with: flavor: | latest=true tags: | type=raw,value=${{ steps.vars.outputs.sha }} - uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 id: push with: tags: ${{ steps.image-tag.outputs.tags }} push: true platforms: linux/amd64,linux/arm64 sbom: true provenance: true context: . build-args: | BUILD=${{ steps.vars.outputs.build }} GIT_BUILD_HASH=${{ steps.vars.outputs.sha }} GRAVITY_BUILD_ARGS=GO_BUILD_FLAGS=-tags=debug labels: ${{ steps.meta.outputs.labels }} - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v3 if: ${{ github.ref == 'refs/heads/main' }} with: subject-name: ghcr.io/beryju/gravity subject-digest: ${{ steps.push.outputs.digest }} push-to-registry: true comment-pr: name: Comment PR image tags runs-on: ubuntu-latest if: ${{ github.event_name == 'pull_request' }} needs: [build, build-debug] permissions: pull-requests: write steps: - id: find-comment uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4 with: issue-number: ${{ github.event.pull_request.number }} comment-author: github-actions[bot] body-includes: - uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5 with: comment-id: ${{ steps.find-comment.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} edit-mode: replace body: | ## Docker Images This PR has been built and pushed to the container registry. **Standard image:** ``` docker pull ghcr.io/beryju/gravity:pr-${{ github.event.pull_request.number }} ``` **Debug image:** ``` docker pull ghcr.io/beryju/gravity:pr-${{ github.event.pull_request.number }}-debug ``` build-cli: name: Build CLI runs-on: ubuntu-latest if: ${{ github.ref == 'refs/heads/main' }} strategy: matrix: arch: [arm64, amd64] os: [darwin, linux] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v5 - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: go.mod cache: true - run: | GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make bin/gravity-cli build-web: name: Build Web runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v5 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v5 with: node-version-file: web/package.json cache: "npm" cache-dependency-path: web/package-lock.json - run: make web-install gen-client-ts web-build