Skip to content

Commit

Permalink
refactor: Configure environment variables in CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
absternator committed Sep 4, 2024
1 parent c32b7fd commit f0b1817
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/jestCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: ./app/server/package-lock.json
- name: configure env variables
run: ./scripts/decrypt_config
- run: npm ci
- name: run all components
working-directory: .
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/playwrightCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: ./app/client-v2/package-lock.json
- name: configure env variables
run: ./scripts/decrypt_config
- name: Run all components
working-directory: .
run: ./scripts/run_test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ app/server/coverage
.idea
proxy/ssl/production
.vscode
.env

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ docker --version
```


If you run the application for the first time in development you need to add the secrets into `env.development`. Run the following command to decrypt the secrets:
If you run the application for the first time in development you need to env variables into `.env`.

Login to the vault:
```
Expand Down Expand Up @@ -78,7 +78,7 @@ You can also run everything outside pm2, by separately running:
- `./scripts/run_client`

## Config
Config for the back-end should be done via env variables. All needed variables can be found at `./app/server/src/buildConfig.ts`. In development, these are set in `./app/server/.env.development`.
Config for the back-end should be done via env variables. All needed variables can be found at `./app/server/src/buildConfig.ts`. In development, these are set in `./app/server/.env` which can be set by running `./scripts/decrypt_config`.

## Deploying with docker

Expand Down
6 changes: 0 additions & 6 deletions app/server/.env.development

This file was deleted.

2 changes: 1 addition & 1 deletion app/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { handleError } from "./errors/handleError";
import { initialiseLogging } from "./logging";
import { buildConfig } from "./buildConfig";

dotenv.config({ path: ".env.development" });
dotenv.config();

const config = buildConfig();

Expand Down
2 changes: 1 addition & 1 deletion app/server/tests/integration/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import MockStrategy from "passport-mock-strategy";
import dotenv from "dotenv";
import { buildConfig } from "../../src/buildConfig";

dotenv.config({ path: ".env.development" });
dotenv.config();
const config = buildConfig();
const app = express();
configureApp(app, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import dotenv from "dotenv";
import { buildConfig } from "../../../src/buildConfig";

const mockAxios = new MockAdapter(axios);
dotenv.config({ path: ".env.development" });
dotenv.config();
const config = buildConfig()

describe("projectController", () => {
Expand Down
8 changes: 6 additions & 2 deletions scripts/decrypt_config
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ mkdir proxy/ssl/production -p
vault read -field=key secret/beebop/ssl/production > proxy/ssl/production/key.pem
vault read -field=cert secret/beebop/ssl/production > proxy/ssl/production/certificate.pem

envsubst >> app/server/.env.development <<EOF
envsubst > app/server/.env <<EOF
SERVER_PORT=4000
API_URL=http://localhost:5000
CLIENT_URL=http://localhost:5173
SERVER_URL=http://localhost:4000
REDIS_URL=redis://localhost:6379
GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID
GOOGLE_CLIENT_SECRET=$GOOGLE_CLIENT_SECRET
SESSION_SECRET=$SESSION_SECRET
Expand Down

0 comments on commit f0b1817

Please sign in to comment.