diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..114c08b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,56 @@ +name: Build and publish image + +on: + push: + branches: [ main ] + tags: [ 'v*' ] + +# Only one build per ref at a time; cancel superseded main builds. +concurrency: + group: build-${{ github.ref }} + cancel-in-progress: ${{ github.ref == 'refs/heads/main' }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write # Required to push to GHCR + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract image metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=edge,branch=main + type=sha,prefix=sha-,format=short,enable={{is_default_branch}} + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + flavor: | + latest=auto + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max