Make errors more explicit when Deploy Action fails because of an invalid or expired API TOKEN.
A customer ran into this issue yesterday when using the Astro deploy action:
# 🚀 Deploy to Astronomer
- name: Deploy to Astronomer
uses: astronomer/deploy-action@v0.10.1
with:
deployment-id: ${{ vars.ASTRO_DEPLOYMENT_ID_DEV }}
deploy-type: image-and-dags
image-name: customer-astro-image
The stacktrace from the ACTION below:
# infer based on files changed to deploy only dags or image and dags
echo ::group::Get Deploy Type
if [[ "" != "" ]]; then
cd
fi
DAGS_ONLY_DEPLOY=false
SKIP_IMAGE_OR_DAGS_DEPLOY=false
files=()
GITHUB_EVENT_BEFORE=[REDACTED]
GITHUB_EVENT_AFTER=[REDACTED]
# case when the triggered event is a manual workflow dispatch or a new branch or tag creation, we would need to deploy the image because we cannot determine that it does not need to be deployed
if [[ "$GITHUB_EVENT_BEFORE" == "0000000000000000000000000000000000000000" || -z $GITHUB_EVENT_BEFORE && -z $GITHUB_EVENT_AFTER ]]; then
echo "Manual workflow dispatch or a new branch or tag creation, hence missing github event before and/or after commit hash"
else
echo "event that triggered the workflow: $GITHUB_REF"
branch=$(echo "${GITHUB_REF#refs/heads/}")
git fetch origin $branch
if ! git cat-file -e "[REDACTED]" 2>/dev/null; then
echo "Commit [REDACTED] does not exist, falling back to image deploy."
else
SKIP_IMAGE_OR_DAGS_DEPLOY=true
files=$(git diff --name-only [REDACTED] [REDACTED])
echo "files changed: $files"
fi
fi
for file in $files; do
if [[ $file =~ ^"".* ]]; then
echo $file is part of the input root folder
SKIP_IMAGE_OR_DAGS_DEPLOY=false
if [[ infer == 'infer' ]]; then
if [[ $file == *"dags/"* ]]; then
echo $file is part of dags folder
DAGS_ONLY_DEPLOY=true
else
DAGS_ONLY_DEPLOY=false
break
fi
elif [[ infer == 'dags-only' ]]; then
if [[ $file == *"dags/"* ]]; then
echo $file is part of dags folder
DAGS_ONLY_DEPLOY=true
fi
elif [[ infer == 'image-and-dags' ]]; then
DAGS_ONLY_DEPLOY=false
break
fi
fi
done
# Note: the order of these following checks is important to ensure that we skip/trigger deploy correctly in following cases:
# 1. When there is no change in the input root folder we should skip deploy, but not when it's deployment preview create action
# 2. When user has passed a custom image then we would need to deploy the image
# 3. When the action is deployment preview delete, then we should skip any form of deploy
if [[ $SKIP_IMAGE_OR_DAGS_DEPLOY == true ]]; then
# skip all deploy steps
DAGS_ONLY_DEPLOY=false
fi
# check if user has passed a custom image or the action has created a new deployment preview, then we would need to deploy the image
if [[ customer-astro-image != "no-custom-image" || == false || deploy == create-deployment-preview ]]; then
SKIP_IMAGE_OR_DAGS_DEPLOY=false
DAGS_ONLY_DEPLOY=false
fi
if [[ deploy == delete-deployment-preview ]]; then
# skip all deploy steps
SKIP_IMAGE_OR_DAGS_DEPLOY=true
DAGS_ONLY_DEPLOY=false
fi
echo "DAGS_ONLY_DEPLOY=$DAGS_ONLY_DEPLOY" >> $GITHUB_OUTPUT
echo "SKIP_IMAGE_OR_DAGS_DEPLOY=$SKIP_IMAGE_OR_DAGS_DEPLOY" >> $GITHUB_OUTPUT
echo ::endgroup::
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
ASTRO_API_TOKEN:
ARTIFACTORY_USER: ***
ARTIFACTORY_PWD: ***
GITHUB_USER: ***
GITHUB_TOKEN: ***
PIP_EXTRA_INDEX_URL: ***[REDACTED]
Get Deploy Type
event that triggered the workflow: refs/heads/dev
From [REDACTED]
* branch dev -> FETCH_HEAD
files changed: tests/HOW_TO_TEST_A_DAG.md
tests/dags/test_etl_dag.py
tests/HOW_TO_TEST_A_DAG.md is part of the input root folder
[REDACTED].sh: line 65: conditional binary operator expected
The line in question is:
if [[ customer-astro-image != "no-custom-image" || == false || deploy == create-deployment-preview ]]; then
When reverting to a previous version of the deploy 0.9.0, it complained that it was not logged in. This led to the solution to the problem, which was that the API_TOKEN was incorrect. Once they fixed this, the above error was fixed.
Make errors more explicit when Deploy Action fails because of an invalid or expired API TOKEN.
A customer ran into this issue yesterday when using the Astro deploy action:
The stacktrace from the ACTION below:
The line in question is:
if [[ customer-astro-image != "no-custom-image" || == false || deploy == create-deployment-preview ]]; thenWhen reverting to a previous version of the deploy 0.9.0, it complained that it was not logged in. This led to the solution to the problem, which was that the API_TOKEN was incorrect. Once they fixed this, the above error was fixed.