Skip to content

Commit a199fb2

Browse files
committed
break up massive shell
1 parent e295fbb commit a199fb2

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

.github/workflows/workflow-run-docker-rust-build.yaml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -112,45 +112,46 @@ jobs:
112112
GIT_SHA: ${{ env.GIT_SHA }}
113113
GCP_DOCKER_ARTIFACT_REPO: ${{ env.GCP_DOCKER_ARTIFACT_REPO }}
114114
WAIT_FOR_IMAGE_SECONDS: 1
115-
116-
- name: Setup GCloud
117-
uses: google-github-actions/setup-gcloud@v2
118-
with:
119-
install_components: 'gcloud'
120115

121116
- name: Authenticate to Google Cloud
122117
id: auth
123118
uses: "google-github-actions/auth@v2"
124119
with:
125120
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
126121
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT_EMAIL }}
127-
128-
- name: Configure GCloud
129-
run: |
130-
gcloud config set project aptos-ci
131-
132-
- name: Lock File Check and Lock if not exists
122+
123+
- name: Check if lock file exists
133124
id: check-lock
134125
if: steps.check-images.outcome == 'failure'
135-
run: |
136-
echo "Checking lock file"
126+
run: |
137127
set +e
138128
gcloud storage ls gs://${{ env.GCP_DOCKER_BUILD_LOCK_BUCKET }}/${{ env.GIT_SHA }}.txt
139-
result=$?
140-
set -e
141-
if [ $result -eq 0 ]; then
142-
echo "Lock file exists: Current workflow building: "
143-
gcloud storage cat gs://${{ env.GCP_DOCKER_BUILD_LOCK_BUCKET }}/${{ env.GIT_SHA }}.txt
144-
echo "Rerun again when the image is finished building" && exit 1
129+
if [ $? -eq 0 ]; then
130+
echo "lock-exists=true" >> $GITHUB_OUTPUT
145131
else
146-
echo "Lock file does not exist"
147-
echo "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" > ${GIT_SHA}.txt
148-
gcloud storage cp ${GIT_SHA}.txt gs://${GCP_DOCKER_BUILD_LOCK_BUCKET}/${GIT_SHA}.txt
149-
echo "Docker Build locked"
132+
echo "lock-exists=false" >> $GITHUB_OUTPUT
150133
fi
151134
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+
152152
- name: Build and Push Rust images
153153
run: docker/builder/docker-bake-rust-all.sh
154+
if: steps.create-lock.outcome == 'success'
154155
env:
155156
PROFILE: ${{ env.PROFILE }}
156157
FEATURES: ${{ env.FEATURES }}
@@ -159,6 +160,7 @@ jobs:
159160
TARGET_REGISTRY: ${{ env.TARGET_REGISTRY }}
160161

161162
- name: Prepare Docker for Caching
163+
if: steps.create-lock.outcome == 'success'
162164
run: |
163165
if [ ! -f /home/runner/docker-cache.tzst ]; then
164166
sudo systemctl stop docker

0 commit comments

Comments
 (0)