|
| 1 | +name: CD |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + tags: |
| 7 | + - 'v*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: Build for ${{ matrix.platform }} |
| 12 | + runs-on: ${{ matrix.runs-on }} |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - platform: linux/amd64 |
| 17 | + runs-on: ubuntu-latest |
| 18 | + arch: amd64 |
| 19 | + - platform: linux/arm64 |
| 20 | + runs-on: ubuntu-24.04-arm |
| 21 | + arch: arm64 |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Build dist directory |
| 28 | + run: make build |
| 29 | + |
| 30 | + - name: Set up Docker Buildx |
| 31 | + uses: docker/setup-buildx-action@v2 |
| 32 | + |
| 33 | + - name: Docker metadata |
| 34 | + id: meta |
| 35 | + uses: docker/metadata-action@v4 |
| 36 | + with: |
| 37 | + images: ghcr.io/${{ github.repository }} |
| 38 | + flavor: | |
| 39 | + suffix=-${{ matrix.arch }} |
| 40 | + tags: | |
| 41 | + type=raw,value=latest |
| 42 | + type=sha |
| 43 | + type=ref,event=tag |
| 44 | +
|
| 45 | + - name: Log in to GitHub Container Registry |
| 46 | + uses: docker/login-action@v2 |
| 47 | + with: |
| 48 | + registry: ghcr.io |
| 49 | + username: ${{ github.actor }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + - name: Build and push single-platform Docker image |
| 53 | + uses: docker/build-push-action@v4 |
| 54 | + with: |
| 55 | + context: . |
| 56 | + push: true |
| 57 | + platforms: ${{ matrix.platform }} |
| 58 | + tags: ${{ steps.meta.outputs.tags }} |
| 59 | + labels: ${{ steps.meta.outputs.labels }} |
| 60 | + cache-from: type=gha,scope=${{ matrix.platform }} |
| 61 | + cache-to: type=gha,mode=max,scope=${{ matrix.platform }} |
| 62 | + |
| 63 | + merge-manifests: |
| 64 | + name: Merge Multi-Arch Manifests |
| 65 | + needs: build |
| 66 | + runs-on: ubuntu-latest |
| 67 | + permissions: |
| 68 | + contents: read |
| 69 | + packages: write |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Set up Docker Buildx |
| 73 | + uses: docker/setup-buildx-action@v2 |
| 74 | + |
| 75 | + - name: Docker metadata for final image |
| 76 | + id: meta |
| 77 | + uses: docker/metadata-action@v4 |
| 78 | + with: |
| 79 | + images: ghcr.io/${{ github.repository }} |
| 80 | + tags: | |
| 81 | + type=raw,value=latest |
| 82 | + type=sha |
| 83 | + type=ref,event=tag |
| 84 | +
|
| 85 | + - name: Log in to GitHub Container Registry |
| 86 | + uses: docker/login-action@v2 |
| 87 | + with: |
| 88 | + registry: ghcr.io |
| 89 | + username: ${{ github.actor }} |
| 90 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + |
| 92 | + - name: Create and push manifest list |
| 93 | + uses: docker/build-push-action@v4 |
| 94 | + with: |
| 95 | + push: true |
| 96 | + tags: ${{ steps.meta.outputs.tags }} |
| 97 | + labels: ${{ steps.meta.outputs.labels }} |
| 98 | + platforms: linux/amd64,linux/arm64 |
| 99 | + cache-from: type=gha |
| 100 | + cache-to: type=gha,mode=max |
0 commit comments