generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 54
Create a mechanism to fail the CD when required environment variables are missing | issue#257 - 2 #285
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
Merged
prakashchoudhary07
merged 10 commits into
Real-Dev-Squad:develop
from
Saitharun279:feature/issue#257-2
Nov 7, 2024
Merged
Create a mechanism to fail the CD when required environment variables are missing | issue#257 - 2 #285
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
327bff8
issue#257 | Madge changes to fail CD when required env are missing
Saitharun279 e29109b
use loadEnv method in register.ts
Saitharun279 1802ad4
rename to env in register.ts
Saitharun279 fe7938f
Merge branch 'develop' into feature/issue#257-2
Saitharun279 00bb90f
renamed env in inedx.ts
Saitharun279 a7b5a82
renamed variables
Saitharun279 e86e851
removed unnecessary comments
Saitharun279 0a1523a
removed redundant comments
Saitharun279 84b2a25
fixed code format
Saitharun279 a9e0c52
format fix
Saitharun279 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,36 @@ on: | |
push: | ||
branches: main | ||
jobs: | ||
Environment-Variables-Check: | ||
runs-on: ubuntu-latest | ||
environment: production | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.18.2 | ||
- run: npm install | ||
- run: npm run env-var-check | ||
env: | ||
CURRENT_ENVIRONMENT: production | ||
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: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v3 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.18.2 | ||
- run: npm install | ||
|
@@ -22,7 +46,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
environment: production | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- run: npm install | ||
- uses: cloudflare/[email protected] | ||
with: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,36 @@ on: | |
push: | ||
branches: develop | ||
jobs: | ||
Environment-Variables-Check: | ||
runs-on: ubuntu-latest | ||
environment: staging | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.18.2 | ||
- run: npm install | ||
- run: npm run env-var-check | ||
env: | ||
CURRENT_ENVIRONMENT: staging | ||
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: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v3 | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.18.2 | ||
- run: npm install | ||
|
@@ -22,7 +46,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
environment: staging | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- run: npm install | ||
- uses: cloudflare/[email protected] | ||
with: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { env } from "../src/typeDefinitions/default.types"; | ||
import { loadEnv } from "./config"; | ||
|
||
/** | ||
* Validate if all the required environment variables are set to a non empty value | ||
* else throw an error | ||
* --- | ||
*/ | ||
export function validateEnv() { | ||
const env: env = loadEnv({}, false); | ||
const missingEnvVariables = Object.keys(env).filter((key) => env[key] == ""); | ||
|
||
if (missingEnvVariables.length > 0) { | ||
throw new Error( | ||
`Missing environment variables: ${missingEnvVariables.join(", ")}` | ||
); | ||
} else { | ||
console.log("All required environment variables are set."); | ||
} | ||
} | ||
|
||
validateEnv(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.