13
13
runs-on : ubuntu-latest
14
14
strategy :
15
15
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']
18
18
permissions :
19
19
packages : write
20
20
steps :
@@ -45,17 +45,27 @@ jobs:
45
45
password : ${{ secrets.GITHUB_TOKEN }}
46
46
47
47
- name : Check if image exists
48
- id : check-image
49
48
run : |
50
49
EXISTS=$(docker manifest inspect ${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:${{ env.DIR_HASH }} > /dev/null 2>&1 && echo "true" || echo "false")
51
50
echo "CACHE_HIT=$EXISTS" >> $GITHUB_ENV
52
51
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
+
53
63
- name : Set up Docker Buildx
54
- if : env.CACHE_HIT == 'false'
64
+ if : env.CACHE_HIT == 'false' && env.PLATFORM_BUILD == 'true'
55
65
uses : docker/setup-buildx-action@v3
56
66
57
67
- 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'
59
69
uses : docker/build-push-action@v6
60
70
with :
61
71
context : .
@@ -64,10 +74,10 @@ jobs:
64
74
tags : ${{ steps.dockerMetadata.outputs.tags }}
65
75
cache-from : type=gha,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }}
66
76
cache-to : type=gha,mode=min,ref=builder-image-cache-${{ hashFiles('conanfile.py', 'Dockerfile') }}
67
- platforms : ' linux/amd64 '
77
+ platforms : ${{ matrix.platform }}
68
78
69
79
- 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'
71
81
run : |
72
82
TAGS=(${{ steps.dockerMetadata.outputs.tags }})
73
83
for TAG in "${TAGS[@]}"; do
0 commit comments