GitHub Actions Multi-Arch Docker Build & Push to GHCR
plain (yaml)
13 hours ago
·
56 lines
·
6 views
1name: Build and Publish Docker Image
3on:
4 push:
5 branches: [main]
6 tags: ['v*.*.*']
8env:
9 REGISTRY: ghcr.io
10 IMAGE_NAME: ${{ github.repository }}
12jobs:
13 build-and-push:
14 runs-on: ubuntu-latest
15 permissions:
16 contents: read
17 packages: write
19 steps:
20 - name: Checkout repository
21 uses: actions/checkout@v4
23 - name: Set up QEMU for multi-arch
24 uses: docker/setup-qemu-action@v3
26 - name: Set up Docker Buildx
27 uses: docker/setup-buildx-action@v3
29 - name: Log in to GitHub Container Registry
30 uses: docker/login-action@v3
31 with:
32 registry: ${{ env.REGISTRY }}
33 username: ${{ github.actor }}
34 password: ${{ secrets.GITHUB_TOKEN }}
36 - name: Extract Docker metadata
37 id: meta
38 uses: docker/metadata-action@v5
39 with:
40 images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41 tags: |
42 type=ref,event=branch
43 type=semver,pattern={{version}}
44 type=sha,format=short
46 - name: Build and push Docker image
47 uses: docker/build-push-action@v5
48 with:
49 context: .
50 platforms: linux/amd64,linux/arm64
51 push: true
52 tags: ${{ steps.meta.outputs.tags }}
53 labels: ${{ steps.meta.outputs.labels }}
54 cache-from: type=gha
55 cache-to: type=gha,mode=max
Replies 0
No replies yet
Every reply is a note. Start a discussion, ask a question, or attach a code snippet.
Notification