|
| 1 | +name: Docker build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - dev |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + # Use docker.io for Docker Hub if empty |
| 11 | + REGISTRY: ghcr.io |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + # This is used to complete the identity challenge |
| 20 | + # with sigstore/fulcio when running outside of PRs. |
| 21 | + id-token: write |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 26 | + |
| 27 | + # Workaround: https://github.com/docker/build-push-action/issues/461 |
| 28 | + - name: Setup Docker buildx |
| 29 | + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3 |
| 30 | + |
| 31 | + - name: Log into registry ${{ env.REGISTRY }} |
| 32 | + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3 |
| 33 | + with: |
| 34 | + registry: ${{ env.REGISTRY }} |
| 35 | + username: ${{ github.actor }} |
| 36 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + |
| 38 | + - name: Extract Docker metadata |
| 39 | + id: meta |
| 40 | + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5 |
| 41 | + with: |
| 42 | + images: ${{ env.REGISTRY }}/${{ github.repository }} |
| 43 | + tags: | |
| 44 | + type=schedule |
| 45 | + type=ref,event=branch |
| 46 | + type=ref,event=tag |
| 47 | + type=raw,value=latest,enable={{is_default_branch}} |
| 48 | +
|
| 49 | + - name: Build and push Docker image |
| 50 | + id: build-and-push |
| 51 | + uses: docker/build-push-action@31159d49c0d4756269a0940a750801a1ea5d7003 # v6 |
| 52 | + with: |
| 53 | + context: . |
| 54 | + push: true |
| 55 | + platforms: linux/amd64,linux/386,linux/arm/v6,linux/arm/v7,linux/arm64 |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + labels: ${{ steps.meta.outputs.labels }} |
| 58 | + cache-from: type=gha |
| 59 | + cache-to: type=gha,mode=max |
0 commit comments