read YAML file for environment variable, and update deployment conditions in pipeline-test.yaml.
Some checks reported warnings
Build and Deploy Hugo Site / build_and_deploy (push) Has been cancelled

This commit is contained in:
Andreas Hnida 2024-04-17 23:08:33 +02:00
commit 18f4bf0496
2 changed files with 8 additions and 51 deletions

View file

@ -10,28 +10,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.4.0
- name: Set Environment
id: set-env
run: |
# 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"
- name: env-yaml-file
uses: pietrobolcato/action-read-yaml@main
id: read_action_js
with:
config: ${{ github.workspace }}/deploy_env.yaml
env-var-prefix: myEnv
- name: Set up Go
uses: actions/setup-go@v5.0.0
with:
@ -74,7 +60,7 @@ jobs:
run: hugo --minify
- name: Deploy to Server
if: ${{ github.job.outputs.environment == 'development' }}
if: $myEnv_environment_name == 'development'
uses: SamKirkland/FTP-Deploy-Action@4.0.0
with:
protocol: ftps

View file

@ -1,29 +0,0 @@
name: helpers-read-yaml
on:
push:
workflow_dispatch:
jobs:
read-yaml:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: read-yaml-file
uses: pietrobolcato/action-read-yaml@main
id: read_action_js
with:
config: ${{ github.workspace }}/config_example_env.yaml
env-var-prefix: myEnv
- name: use-yaml-file
run: |
echo environment name: $myEnv_environment_name
echo first permission name: $myEnv_environment_permissions_0_name
echo first permission permissions: $myEnv_environment_permissions_0_permission
echo second permission name: $myEnv_environment_permissions_1_name
echo second permission permissions: $myEnv_environment_permissions_1_permission
echo deployment source libs: $myEnv_deployment_code_source_libs
echo deployment source entry: $myEnv_deployment_code_source_entry