|
17 | 17 | required: false |
18 | 18 | type: string |
19 | 19 | description: "Custom output destinations for docker build (e.g., type=registry,push=true,compression=gzip,force-compression=true). Required for DHI images." |
20 | | - docker-build-platforms: |
| 20 | + docker-build-platform: |
21 | 21 | required: false |
22 | 22 | type: string |
23 | 23 | default: "linux/amd64" |
@@ -105,47 +105,28 @@ on: |
105 | 105 | required: false |
106 | 106 |
|
107 | 107 | jobs: |
108 | | - prepare-matrix: |
109 | | - runs-on: ubuntu-latest |
110 | | - outputs: |
111 | | - matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 108 | + check-single-platform: |
| 109 | + name: Check if only a single platform is built |
| 110 | + runs-on: ubuntu-slim |
112 | 111 | steps: |
113 | | - - name: Generate Matrix |
114 | | - id: set-matrix |
115 | | - shell: python |
| 112 | + - name: Check if only a single platform is built |
| 113 | + id: check_single_platform |
116 | 114 | run: | |
117 | | - import os |
118 | | - import json |
| 115 | + platform="${{ inputs.docker-build-platform }}" |
| 116 | + platform_count=$(echo "$platform" | tr ',' '\n' | wc -l) |
| 117 | + if [ "$platform_count" -gt 1 ]; then |
| 118 | + echo "Multiple platforms are built: ${platform}" |
| 119 | + echo "::error::This action only supports one platform and no cross compiling." |
| 120 | + exit 1 |
| 121 | + else |
| 122 | + echo "Only a single platform is built: ${platform}" |
| 123 | + fi |
119 | 124 |
|
120 | | - platforms_input = "${{ inputs.docker-build-platforms }}" |
121 | | - amd64_runner = "${{ inputs.runs-on }}" |
122 | | - arm64_runner = "${{ inputs.runs-on-arm }}" |
123 | | -
|
124 | | - # split input "linux/amd64,linux/arm64" into list |
125 | | - platforms = [p.strip() for p in platforms_input.split(',') if p.strip()] |
126 | | -
|
127 | | - include = [] |
128 | | - for p in platforms: |
129 | | - runner = amd64_runner |
130 | | - # Map linux/arm64 to a specific ARM runner |
131 | | - # Adjust 'ubuntu-24.04-arm' to GitHub availability |
132 | | - if "arm64" in p: |
133 | | - runner = arm64_runner |
134 | | -
|
135 | | - include.append({"platform": p, "runner": runner}) |
136 | | -
|
137 | | - matrix = {"include": include} |
138 | | -
|
139 | | - with open(os.environ['GITHUB_OUTPUT'], 'a') as f: |
140 | | - f.write(f"matrix={json.dumps(matrix)}") |
141 | 125 |
|
142 | 126 | gitops: |
143 | | - name: GitOps (${{ matrix.platform }}) |
144 | | - needs: prepare-matrix |
145 | | - strategy: |
146 | | - fail-fast: true |
147 | | - matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} |
148 | | - runs-on: ${{ matrix.runner }} |
| 127 | + name: GitOps (${{ inputs.docker-build-platform }}) |
| 128 | + needs: check-single-platform |
| 129 | + runs-on: ${{ inputs.docker-build-platform == 'linux/arm64' && inputs.runs-on-arm || inputs.runs-on }} |
149 | 130 | if: github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') |
150 | 131 |
|
151 | 132 | env: |
|
0 commit comments