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
Some checks failed
Build and Deploy Hugo Site / build_and_deploy (push) Failing after 13s
This commit is contained in:
parent
0be583ff98
commit
cb2283aa75
1 changed files with 19 additions and 3 deletions
|
|
@ -13,9 +13,25 @@ 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
|
||||||
echo "::set-output name=environment::$ENV"
|
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"
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5.0.0
|
uses: actions/setup-go@v5.0.0
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue