Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a mechanism to fail the CD when required environment variables are missing | issue#257 #274

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/register-commands-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,36 @@ on:
push:
branches: main
jobs:
Environment-Variables-Check:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v2
- run: bash environment-variables-validator.sh
env:
ENV_VAR_NAMES: |
DISCORD_APPLICATION_ID
DISCORD_GUILD_ID
DISCORD_TOKEN
DISCORD_PUBLIC_KEY
CLOUDFLARE_API_TOKEN
CLOUDFLARE_ACCOUNT_ID
BOT_PRIVATE_KEY
RDS_SERVERLESS_PUBLIC_KEY
CRON_JOBS_PUBLIC_KEY
IDENTITY_SERVICE_PUBLIC_KEY
DISCORD_APPLICATION_ID: ${{secrets.DISCORD_APPLICATION_ID}}
DISCORD_GUILD_ID: ${{secrets.DISCORD_GUILD_ID}}
DISCORD_TOKEN: ${{secrets.DISCORD_TOKEN}}
DISCORD_PUBLIC_KEY: ${{secrets.DISCORD_PUBLIC_KEY}}
CLOUDFLARE_API_TOKEN: ${{secrets.CLOUDFLARE_API_TOKEN}}
CLOUDFLARE_ACCOUNT_ID: ${{secrets.CLOUDFLARE_ACCOUNT_ID}}
BOT_PRIVATE_KEY: ${{secrets.BOT_PRIVATE_KEY}}
RDS_SERVERLESS_PUBLIC_KEY: ${{secrets.RDS_SERVERLESS_PUBLIC_KEY}}
CRON_JOBS_PUBLIC_KEY: ${{secrets.CRON_JOBS_PUBLIC_KEY}}
IDENTITY_SERVICE_PUBLIC_KEY: ${{secrets.IDENTITY_SERVICE_PUBLIC_KEY}}
Register-Commands:
needs: [Environment-Variables-Check]
runs-on: ubuntu-latest
environment: production
steps:
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/register-commands-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,36 @@ on:
push:
branches: develop
jobs:
Environment-Variables-Check:
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v2
- run: bash environment-variables-validator.sh
env:
ENV_VAR_NAMES: |
DISCORD_APPLICATION_ID
DISCORD_GUILD_ID
DISCORD_TOKEN
DISCORD_PUBLIC_KEY
CLOUDFLARE_API_TOKEN
CLOUDFLARE_ACCOUNT_ID
BOT_PRIVATE_KEY
RDS_SERVERLESS_PUBLIC_KEY
CRON_JOBS_PUBLIC_KEY
IDENTITY_SERVICE_PUBLIC_KEY
DISCORD_APPLICATION_ID: ${{secrets.DISCORD_APPLICATION_ID}}
DISCORD_GUILD_ID: ${{secrets.DISCORD_GUILD_ID}}
DISCORD_TOKEN: ${{secrets.DISCORD_TOKEN}}
DISCORD_PUBLIC_KEY: ${{secrets.DISCORD_PUBLIC_KEY}}
CLOUDFLARE_API_TOKEN: ${{secrets.CLOUDFLARE_API_TOKEN}}
CLOUDFLARE_ACCOUNT_ID: ${{secrets.CLOUDFLARE_ACCOUNT_ID}}
BOT_PRIVATE_KEY: ${{secrets.BOT_PRIVATE_KEY}}
RDS_SERVERLESS_PUBLIC_KEY: ${{secrets.RDS_SERVERLESS_PUBLIC_KEY}}
CRON_JOBS_PUBLIC_KEY: ${{secrets.CRON_JOBS_PUBLIC_KEY}}
IDENTITY_SERVICE_PUBLIC_KEY: ${{secrets.IDENTITY_SERVICE_PUBLIC_KEY}}
Register-Commands:
needs: [Environment-Variables-Check]
runs-on: ubuntu-latest
environment: staging
steps:
Expand Down
10 changes: 10 additions & 0 deletions environment-variables-validator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

for var_name in $ENV_VAR_NAMES; do
# Check if the variable is set in the environment
if [[ -z "${!var_name}" ]]; then
echo "Environment variable $var_name is not set."
exit 1 # Exit with error if any variable is not set
fi
done
echo "All Environment variables are set."