chore: updated docker workflow to support aarch64
04e88cea
1 file(s) · +76 −10
| 65 | 65 | fi |
|
| 66 | 66 | ||
| 67 | 67 | build: |
|
| 68 | - | name: build (${{ matrix.app }}) |
|
| 68 | + | name: build (${{ matrix.app }}/${{ matrix.platform.arch }}) |
|
| 69 | 69 | needs: changes |
|
| 70 | 70 | if: needs.changes.outputs.apps != '[]' |
|
| 71 | - | runs-on: ubuntu-latest |
|
| 71 | + | runs-on: ${{ matrix.platform.runner }} |
|
| 72 | 72 | permissions: |
|
| 73 | 73 | contents: read |
|
| 74 | 74 | packages: write |
|
| 76 | 76 | fail-fast: false |
|
| 77 | 77 | matrix: |
|
| 78 | 78 | app: ${{ fromJson(needs.changes.outputs.apps) }} |
|
| 79 | + | platform: |
|
| 80 | + | - arch: amd64 |
|
| 81 | + | runner: ubuntu-latest |
|
| 82 | + | - arch: arm64 |
|
| 83 | + | runner: ubuntu-24.04-arm |
|
| 79 | 84 | steps: |
|
| 80 | 85 | - uses: actions/checkout@v4 |
|
| 81 | 86 | ||
| 94 | 99 | uses: docker/metadata-action@v5 |
|
| 95 | 100 | with: |
|
| 96 | 101 | images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.app }} |
|
| 97 | - | tags: | |
|
| 98 | - | type=raw,value=${{ needs.changes.outputs.version }},enable=${{ needs.changes.outputs.version != '' }} |
|
| 99 | - | type=raw,value=latest,enable={{is_default_branch}} |
|
| 100 | 102 | ||
| 101 | - | - name: Build and push |
|
| 103 | + | - name: Build and push by digest |
|
| 104 | + | id: build |
|
| 102 | 105 | uses: docker/build-push-action@v6 |
|
| 103 | 106 | with: |
|
| 104 | 107 | context: . |
|
| 105 | 108 | file: apps/${{ matrix.app }}/Dockerfile |
|
| 106 | - | push: true |
|
| 107 | - | tags: ${{ steps.meta.outputs.tags }} |
|
| 109 | + | platforms: linux/${{ matrix.platform.arch }} |
|
| 108 | 110 | labels: ${{ steps.meta.outputs.labels }} |
|
| 109 | - | cache-from: type=gha,scope=${{ matrix.app }} |
|
| 110 | - | cache-to: type=gha,mode=max,scope=${{ matrix.app }} |
|
| 111 | + | cache-from: type=gha,scope=${{ matrix.app }}-${{ matrix.platform.arch }} |
|
| 112 | + | cache-to: type=gha,mode=max,scope=${{ matrix.app }}-${{ matrix.platform.arch }} |
|
| 113 | + | outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.app }},push-by-digest=true,name-canonical=true,push=true |
|
| 114 | + | ||
| 115 | + | - name: Export digest |
|
| 116 | + | run: | |
|
| 117 | + | mkdir -p /tmp/digests |
|
| 118 | + | digest="${{ steps.build.outputs.digest }}" |
|
| 119 | + | touch "/tmp/digests/${digest#sha256:}" |
|
| 120 | + | ||
| 121 | + | - name: Upload digest |
|
| 122 | + | uses: actions/upload-artifact@v4 |
|
| 123 | + | with: |
|
| 124 | + | name: digests-${{ matrix.app }}-${{ matrix.platform.arch }} |
|
| 125 | + | path: /tmp/digests/* |
|
| 126 | + | if-no-files-found: error |
|
| 127 | + | retention-days: 1 |
|
| 128 | + | ||
| 129 | + | merge: |
|
| 130 | + | name: merge (${{ matrix.app }}) |
|
| 131 | + | needs: [changes, build] |
|
| 132 | + | if: needs.changes.outputs.apps != '[]' |
|
| 133 | + | runs-on: ubuntu-latest |
|
| 134 | + | permissions: |
|
| 135 | + | contents: read |
|
| 136 | + | packages: write |
|
| 137 | + | strategy: |
|
| 138 | + | fail-fast: false |
|
| 139 | + | matrix: |
|
| 140 | + | app: ${{ fromJson(needs.changes.outputs.apps) }} |
|
| 141 | + | steps: |
|
| 142 | + | - name: Download digests |
|
| 143 | + | uses: actions/download-artifact@v4 |
|
| 144 | + | with: |
|
| 145 | + | path: /tmp/digests |
|
| 146 | + | pattern: digests-${{ matrix.app }}-* |
|
| 147 | + | merge-multiple: true |
|
| 148 | + | ||
| 149 | + | - name: Set up Docker Buildx |
|
| 150 | + | uses: docker/setup-buildx-action@v3 |
|
| 151 | + | ||
| 152 | + | - name: Log in to GHCR |
|
| 153 | + | uses: docker/login-action@v3 |
|
| 154 | + | with: |
|
| 155 | + | registry: ${{ env.REGISTRY }} |
|
| 156 | + | username: ${{ github.actor }} |
|
| 157 | + | password: ${{ secrets.GITHUB_TOKEN }} |
|
| 158 | + | ||
| 159 | + | - name: Extract metadata |
|
| 160 | + | id: meta |
|
| 161 | + | uses: docker/metadata-action@v5 |
|
| 162 | + | with: |
|
| 163 | + | images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.app }} |
|
| 164 | + | tags: | |
|
| 165 | + | type=raw,value=${{ needs.changes.outputs.version }},enable=${{ needs.changes.outputs.version != '' }} |
|
| 166 | + | type=raw,value=latest,enable={{is_default_branch}} |
|
| 167 | + | ||
| 168 | + | - name: Create manifest list and push |
|
| 169 | + | working-directory: /tmp/digests |
|
| 170 | + | run: | |
|
| 171 | + | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
|
| 172 | + | $(printf '${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.app }}@sha256:%s ' *) |
|
| 173 | + | ||
| 174 | + | - name: Inspect image |
|
| 175 | + | run: | |
|
| 176 | + | docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.app }}:${{ needs.changes.outputs.version != '' && needs.changes.outputs.version || 'latest' }} |
|