feat: check if zip file is valid
- test the zip file to ensure its valid
This commit is contained in:
parent
9cb07d9cef
commit
e33f943526
@ -1,6 +1,7 @@
|
|||||||
name: Deploy
|
name: Deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@ -21,20 +22,27 @@ jobs:
|
|||||||
mkdir -p /workspace/unkin/terraform-nomad/plans
|
mkdir -p /workspace/unkin/terraform-nomad/plans
|
||||||
export RUN_ID=$((GITHUB_RUN_NUMBER - 1))
|
export RUN_ID=$((GITHUB_RUN_NUMBER - 1))
|
||||||
export PLANS_URL="https://git.query.consul/${GITHUB_REPOSITORY}/actions/runs/${RUN_ID}/artifacts/plans"
|
export PLANS_URL="https://git.query.consul/${GITHUB_REPOSITORY}/actions/runs/${RUN_ID}/artifacts/plans"
|
||||||
export MAX_RETRIES=5
|
export MAX_RETRIES=6
|
||||||
export RETRY_COUNT=0
|
export RETRY_COUNT=0
|
||||||
echo "Attempting to download plans from ${PLANS_URL}"
|
echo "Attempting to download plans from ${PLANS_URL}"
|
||||||
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
||||||
curl -L -o /workspace/plans.zip "${PLANS_URL}" && break || true
|
# Download the file
|
||||||
echo "Plans file not available yet. Retrying in 10 seconds... ($((RETRY_COUNT + 1))/$MAX_RETRIES)"
|
curl -L -o /workspace/plans.zip "${PLANS_URL}"
|
||||||
RETRY_COUNT=$((RETRY_COUNT + 1))
|
# Validate if it is a valid ZIP
|
||||||
sleep 10
|
if unzip -t /workspace/plans.zip > /dev/null 2>&1; then
|
||||||
|
echo "Plans file downloaded and verified successfully."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Invalid or corrupt plans file. Retrying in 10 seconds... ($((RETRY_COUNT + 1))/$MAX_RETRIES)"
|
||||||
|
RETRY_COUNT=$((RETRY_COUNT + 1))
|
||||||
|
sleep 10
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
if [ ! -f /workspace/plans.zip ]; then
|
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
||||||
echo "Failed to download plans file after $MAX_RETRIES attempts."
|
echo "Failed to download a valid plans file after $MAX_RETRIES attempts."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Plans file downloaded. Extracting..."
|
echo "Extracting plans..."
|
||||||
unzip /workspace/plans.zip -d /workspace/unkin/terraform-nomad/plans
|
unzip /workspace/plans.zip -d /workspace/unkin/terraform-nomad/plans
|
||||||
echo "Plans file extracted successfully."
|
echo "Plans file extracted successfully."
|
||||||
|
|
||||||
@ -50,4 +58,5 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
|
VAULT_ROLEID: ${{ secrets.TERRAFORM_NOMAD_VAULT_ROLEID }}
|
||||||
run: |
|
run: |
|
||||||
|
env | grep TF_VAR
|
||||||
make apply
|
make apply
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user