From f0c28a9461f86527076f05b423ef83f7b34d1a6f Mon Sep 17 00:00:00 2001 From: Bradley Reynolds Date: Sun, 31 May 2026 12:02:35 -0500 Subject: [PATCH] CI: add image build Signed-off-by: Bradley Reynolds --- .github/workflows/image-build-push.yaml | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/image-build-push.yaml diff --git a/.github/workflows/image-build-push.yaml b/.github/workflows/image-build-push.yaml new file mode 100644 index 0000000..8a23d01 --- /dev/null +++ b/.github/workflows/image-build-push.yaml @@ -0,0 +1,68 @@ +name: Build container image + +on: + push: + branches: + - main + tags: + - "*" + pull_request: + +permissions: + contents: read + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + id-token: write + attestations: write + outputs: + digest: ${{ steps.build-and-push.outputs.digest }} + steps: + - name: Setup Docker buildx + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 + + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=${{ github.sha }} + type=ref,event=tag + type=edge + env: + # ghcr.io prefers index level annotations + DOCKER_METADATA_ANNOTATIONS_LEVELS: index + + - name: Build and push Docker image + id: build-and-push + uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 + with: + file: Dockerfile + push: ${{ github.ref == 'refs/heads/main' || startswith(github.event.ref, 'refs/tags/') }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + annotations: ${{ steps.meta.outputs.annotations }} + build-args: | + git_sha=${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max + provenance: mode=max + sbom: true