Skip to content

Commit 328e3d4

Browse files
committed
correct usage of matrix parameter and also check for the platform
1 parent 44f1712 commit 328e3d4

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

.github/workflows/dependencies.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
args:
17-
${{ contains(github.event_name, 'workflow_dispatch') || github.ref == 'refs/heads/main' ? ['linux/amd64', 'linux/arm64']: [ 'linux/amd64' ] }}
16+
platform:
17+
['linux/amd64', 'linux/arm64']
1818
permissions:
1919
packages: write
2020
steps:
@@ -45,17 +45,27 @@ jobs:
4545
password: ${{ secrets.GITHUB_TOKEN }}
4646

4747
- name: Check if image exists
48-
id: check-image
4948
run: |
5049
EXISTS=$(docker manifest inspect ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }} > /dev/null 2>&1 && echo "true" || echo "false")
5150
echo "CACHE_HIT=$EXISTS" >> $GITHUB_ENV
5251
52+
- name: Determine platform build necessity
53+
id: platform-check
54+
run: |
55+
if [[ "${{ matrix.platform }}" == "linux/amd64" || "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.ref }}" == "refs/heads/main" ]]; then
56+
echo "PLATFORM_BUILD=true" >> $GITHUB_ENV
57+
else
58+
echo "Skipping Platform Build for ${{ matrix.plaform }}"
59+
echo "PLATFORM_BUILD=false" >> $GITHUB_ENV
60+
fi
61+
shell: bash
62+
5363
- name: Set up Docker Buildx
54-
if: env.CACHE_HIT == 'false'
64+
if: env.CACHE_HIT == 'false' && env.PLATFORM_BUILD == 'true'
5565
uses: docker/setup-buildx-action@v3
5666

5767
- name: Build and push image if input files changed
58-
if: env.CACHE_HIT == 'false'
68+
if: env.CACHE_HIT == 'false' && env.PLATFORM_BUILD == 'true'
5969
uses: docker/build-push-action@v6
6070
with:
6171
context: .
@@ -64,10 +74,10 @@ jobs:
6474
tags: ${{ steps.dockerMetadata.outputs.tags }}
6575
cache-from: type=gha,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }}
6676
cache-to: type=gha,mode=min,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }}
67-
platforms: 'linux/amd64'
77+
platforms: ${{ matrix.platform }}
6878

6979
- name: Retag and push existing image if cache hit
70-
if: env.CACHE_HIT == 'true'
80+
if: env.CACHE_HIT == 'true' && env.PLATFORM_BUILD == 'true'
7181
run: |
7282
TAGS=(${{ steps.dockerMetadata.outputs.tags }})
7383
for TAG in "${TAGS[@]}"; do

0 commit comments

Comments
 (0)