@@ -120,38 +120,20 @@ jobs:
120120 workload_identity_provider : ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
121121 service_account : ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}
122122
123- - name : Check if lock file exists
124- id : check-lock
125- if : steps.check-images.outcome == 'failure'
123+ - name : Lock Check and Creation
126124 run : |
127- set +e
128- gcloud storage ls gs://${{ env.GCP_DOCKER_BUILD_LOCK_BUCKET }}/${{ env.GIT_SHA }}.txt
129- if [ $? -eq 0 ]; then
130- echo "lock-exists=true" >> $GITHUB_OUTPUT
125+ echo "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" > ${GIT_SHA}.txt
126+ if gcloud storage cp ${GIT_SHA}.txt gs://${GCP_DOCKER_BUILD_LOCK_BUCKET}/${GIT_SHA}.txt --if-not-exists; then
127+ echo "Lock created successfully"
131128 else
132- echo "lock-exists=false" >> $GITHUB_OUTPUT
129+ echo "Lock already exists"
130+ echo "Checkback when the following workflow is finished building images: "
131+ gcloud storage cat gs://${GCP_DOCKER_BUILD_LOCK_BUCKET}/${GIT_SHA}.txt
132+ exit 1
133133 fi
134134
135- - name : Show lock file content
136- if : steps.check-lock.outputs.lock-exists == 'true'
137- run : |
138- echo "Lock file exists: Current workflow building: "
139- gcloud storage cat gs://${{ env.GCP_DOCKER_BUILD_LOCK_BUCKET }}/${{ env.GIT_SHA }}.txt
140- echo "Rerun again when the image is finished building"
141- exit 1
142-
143- - name : Create and upload lock file
144- id : create-lock
145- if : steps.check-lock.outputs.lock-exists == 'false'
146- run : |
147- echo "Lock file does not exist"
148- echo "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" > ${GIT_SHA}.txt
149- gcloud storage cp ${GIT_SHA}.txt gs://${GCP_DOCKER_BUILD_LOCK_BUCKET}/${GIT_SHA}.txt
150- echo "Docker Build locked"
151-
152135 - name : Build and Push Rust images
153136 run : docker/builder/docker-bake-rust-all.sh
154- if : steps.create-lock.outcome == 'success'
155137 env :
156138 PROFILE : ${{ env.PROFILE }}
157139 FEATURES : ${{ env.FEATURES }}
@@ -160,7 +142,6 @@ jobs:
160142 TARGET_REGISTRY : ${{ env.TARGET_REGISTRY }}
161143
162144 - name : Prepare Docker for Caching
163- if : steps.create-lock.outcome == 'success'
164145 run : |
165146 if [ ! -f /home/runner/docker-cache.tzst ]; then
166147 sudo systemctl stop docker
0 commit comments