|
30 | 30 | IMAGE_SLUG: ${{ github.repository }} |
31 | 31 |
|
32 | 32 | jobs: |
33 | | - # Push image to GitHub Container Registry. |
| 33 | + # Generate shared tags for both architectures |
34 | 34 | # The image tag pattern is: |
35 | 35 | # for pull-requests: <PATCH_VERSION>-<DATE>-<PR_NUMBER>, eg: 1.35.2-20210125-25 |
36 | 36 | # for tags: <TAG> |
37 | 37 | # for `master` branch: latest,<PATCH_VERSION>-latest,<MINOR_VERSION>-latest,<MAJOR_VERSION>-latest,<PATCH_VERSION>-<DATE>-<SHA> |
38 | 38 | # for `development` branch: development,<MAJOR_VERSION>-development,<PATCH_VERSION>-<DATE>-<SHA> |
39 | 39 | # for releases: release,<PATCH_VERSION>-release,<MINOR_VERSION>-release,<MAJOR_VERSION>-release,<PATCH_VERSION>-<DATE>-<SHA> |
40 | 40 | # Version is parsed from package.json |
41 | | - push: |
| 41 | + generate-tags: |
42 | 42 | runs-on: ubuntu-latest |
43 | 43 | if: github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'release' |
| 44 | + outputs: |
| 45 | + registry-tags: ${{ steps.generate.outputs.REGISTRY_TAGS }} |
| 46 | + image-id: ${{ steps.generate.outputs.IMAGE_ID }} |
44 | 47 | steps: |
45 | 48 | - name: Checkout |
46 | 49 | uses: actions/checkout@v3 |
47 | 50 |
|
48 | | - - name: Set up Docker Buildx |
49 | | - uses: docker/setup-buildx-action@v3 |
50 | | - with: |
51 | | - platforms: linux/amd64,linux/arm64 |
52 | | - |
53 | 51 | - name: Generate tags |
54 | 52 | id: generate |
55 | 53 | run: | |
@@ -112,22 +110,47 @@ jobs: |
112 | 110 | echo "REGISTRY_TAGS_PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT |
113 | 111 | echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_OUTPUT |
114 | 112 |
|
| 113 | + # Build and push AMD64 image on x64 runner |
| 114 | + build-amd64: |
| 115 | + needs: generate-tags |
| 116 | + runs-on: ubuntu-latest # x64 runner for native AMD64 builds |
| 117 | + steps: |
| 118 | + - name: Checkout |
| 119 | + uses: actions/checkout@v3 |
| 120 | + |
| 121 | + - name: Set up Docker Buildx |
| 122 | + uses: docker/setup-buildx-action@v3 |
| 123 | + |
115 | 124 | - name: Login to GHCR |
116 | 125 | run: echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} --password-stdin ghcr.io |
117 | 126 |
|
118 | 127 | - name: Docker buildx build and push (AMD64) |
119 | 128 | run: | |
120 | 129 | docker buildx build \ |
121 | 130 | --platform linux/amd64 \ |
122 | | - ${{ steps.generate.outputs.REGISTRY_TAGS }} \ |
| 131 | + ${{ needs.generate-tags.outputs.registry-tags }} \ |
123 | 132 | --push \ |
124 | 133 | --no-cache \ |
125 | 134 | . |
126 | 135 |
|
| 136 | + # Build and push ARM64 image on ARM64 runner |
| 137 | + build-arm64: |
| 138 | + needs: generate-tags |
| 139 | + runs-on: ubuntu-24.04-arm # ARM64 runner for native ARM64 builds |
| 140 | + steps: |
| 141 | + - name: Checkout |
| 142 | + uses: actions/checkout@v3 |
| 143 | + |
| 144 | + - name: Set up Docker Buildx |
| 145 | + uses: docker/setup-buildx-action@v3 |
| 146 | + |
| 147 | + - name: Login to GHCR |
| 148 | + run: echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} --password-stdin ghcr.io |
| 149 | + |
127 | 150 | - name: Docker buildx build and push (ARM64) |
128 | 151 | run: | |
129 | 152 | # Generate ARM64-specific tags by adding -arm64 suffix |
130 | | - ARM64_TAGS=${{ steps.generate.outputs.REGISTRY_TAGS }}-arm64 |
| 153 | + ARM64_TAGS=${{ needs.generate-tags.outputs.registry-tags }}-arm64 |
131 | 154 | docker buildx build \ |
132 | 155 | --platform linux/arm64 \ |
133 | 156 | ${ARM64_TAGS} \ |
|
0 commit comments