Refactor workflow to check for existence and validity of deploy_env.json before setting ENV variable.
Some checks failed
Build and Deploy Hugo Site / build_and_deploy (push) Failing after 13s

This commit is contained in:
Andreas Hnida 2024-04-17 22:01:43 +02:00
commit cb2283aa75

View file

@ -13,7 +13,23 @@ jobs:
- name: Set Environment - name: Set Environment
id: set-env id: set-env
run: | run: |
echo "ENV=$(cat deploy_env.json | jq -r '.env')" >> $GITHUB_ENV # Ensure the deploy_env.json file exists and is readable
if [ ! -f deploy_env.json ]; then
echo "deploy_env.json does not exist or cannot be read."
exit 1
fi
# Extract the environment variable using jq and check if it's empty
ENV=$(cat deploy_env.json | jq -r '.env')
if [ -z "$ENV" ]; then
echo "Environment variable is empty."
exit 1
fi
# Use GitHub's environment file syntax to set the ENV variable
echo "ENV=$ENV" >> $GITHUB_ENV
# Output the environment variable for use in subsequent steps
echo "::set-output name=environment::$ENV" echo "::set-output name=environment::$ENV"
- name: Set up Go - name: Set up Go