Skip to content

Commit b2a8958

Browse files
authored
Added environment variables check job in staging github action
1 parent 15aa15e commit b2a8958

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

.github/workflows/register-commands-staging.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,25 @@ on:
33
push:
44
branches: develop
55
jobs:
6+
Environment-Variables-Check:
7+
runs-on: ubuntu-latest
8+
environment: staging
9+
steps:
10+
- uses: actions/checkout@v2
11+
- run: bash environment-variables-validator.sh
12+
env:
13+
DISCORD_APPLICATION_ID: ${{secrets.DISCORD_APPLICATION_ID}}
14+
CLOUDFLARE_API_TOKEN: ${{secrets.CLOUDFLARE_API_TOKEN}}
15+
DISCORD_PUBLIC_KEY: ${{secrets.DISCORD_PUBLIC_KEY}}
16+
DISCORD_TOKEN: ${{secrets.DISCORD_TOKEN}}
17+
BOT_PRIVATE_KEY: ${{secrets.BOT_PRIVATE_KEY}}
18+
DISCORD_GUILD_ID: ${{secrets.DISCORD_GUILD_ID}}
19+
RDS_SERVERLESS_PUBLIC_KEY: ${{secrets.RDS_SERVERLESS_PUBLIC_KEY}}
20+
CRON_JOBS_PUBLIC_KEY: ${{secrets.CRON_JOBS_PUBLIC_KEY}}
21+
IDENTITY_SERVICE_PUBLIC_KEY: ${{secrets.IDENTITY_SERVICE_PUBLIC_KEY}}
22+
CLOUDFLARE_ACCOUNT_ID: ${{secrets.CLOUDFLARE_ACCOUNT_ID}}
623
Register-Commands:
24+
needs: [Environment-Variables-Check]
725
runs-on: ubuntu-latest
826
environment: staging
927
steps:

environment-variables-validator.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
ENV_VARS_FILE="environment-variables.txt"
4+
# Check if the file exists
5+
if [[ ! -f "$ENV_VARS_FILE" ]]; then
6+
echo "File $ENV_VARS_FILE does not exist."
7+
exit 1
8+
fi
9+
10+
# Read the file and iterate through each variable name
11+
while IFS= read -r var_name; do
12+
# Check if the variable is set in the environment
13+
if [[ -z "${!var_name}" ]]; then
14+
echo "Environment variable $var_name is not set."
15+
exit 1 # Exit with error if any variable is not set
16+
else
17+
echo "Environment variable $var_name is set."
18+
fi
19+
done < "$ENV_VARS_FILE"

environment-variables.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DISCORD_PUBLIC_KEY
2+
DISCORD_TOKEN
3+
DISCORD_GUILD_ID
4+
DISCORD_APPLICATION_ID
5+
CURRENT_ENVIRONMENT
6+
BOT_PRIVATE_KEY
7+
RDS_SERVERLESS_PUBLIC_KEY
8+
CRON_JOBS_PUBLIC_KEY
9+
IDENTITY_SERVICE_PUBLIC_KEY
10+
CLOUDFLARE_ACCOUNT_ID

0 commit comments

Comments
 (0)