From 09bec5ad368de5338f70787a8bbd6df92fb35a48 Mon Sep 17 00:00:00 2001 From: Guy Date: Wed, 6 May 2026 18:57:15 -0700 Subject: [PATCH] Add workflow to build container image --- .dockerignore | 6 +++ .github/workflows/container-image.yml | 64 +++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/container-image.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7b32381 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.github +node_modules +npm-debug.log* +test-results +traces-*.json diff --git a/.github/workflows/container-image.yml b/.github/workflows/container-image.yml new file mode 100644 index 0000000..d239249 --- /dev/null +++ b/.github/workflows/container-image.yml @@ -0,0 +1,64 @@ +name: Publish container image + +on: + push: + branches: + - main + tags: + - "v*.*.*" + pull_request: + workflow_dispatch: + +permissions: + contents: read + packages: write + +env: + REGISTRY: ghcr.io + +jobs: + image: + name: Build container image + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Resolve image name + id: image + run: echo "name=${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract image metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ steps.image.outputs.name }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=sha,prefix=sha- + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and publish image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max