Skip to content

Commit 9d31755

Browse files
authored
Actions variables (#146)
* Refactor workflows to use variables instead of secrets for environment files * Update DevOps guide to replace secrets with variables for GitHub Actions configuration * Bump version to 1.1.0-alpha.1 and update dependencies * Bump version to 1.1.0-alpha.1 in package.json and package-lock.json
1 parent 4a3242a commit 9d31755

11 files changed

Lines changed: 75 additions & 80 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: 'Create .env file'
3939
run: |
40-
echo "${{ secrets.ENV_CI }}" > .env
40+
echo "${{ vars.ENV_CI }}" > .env
4141
4242
- name: Lint
4343
run: npm run lint
@@ -71,7 +71,7 @@ jobs:
7171
- name: Create infrastructure .env file
7272
working-directory: ./infrastructure
7373
run: |
74-
echo "${{ secrets.CDK_ENV_DEV }}" > .env
74+
echo "${{ vars.CDK_ENV_DEV }}" > .env
7575
7676
- name: Configure AWS credentials
7777
uses: aws-actions/configure-aws-credentials@v6.0.0

.github/workflows/code-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: 'Create .env file'
3939
run: |
40-
echo "${{ secrets.ENV_CI }}" > .env
40+
echo "${{ vars.ENV_CI }}" > .env
4141
4242
- name: Run ESLint with detailed output
4343
run: |

.github/workflows/deploy-dev.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ jobs:
1919
with:
2020
aws_role_arn: ${{ vars.AWS_ROLE_ARN_DEV }}
2121
env: dev
22-
secrets:
23-
env_file: ${{ secrets.ENV_DEV }}
24-
cdk_env_file: ${{ secrets.CDK_ENV_DEV }}
22+
env_file: ${{ vars.ENV_DEV }}
23+
cdk_env_file: ${{ vars.CDK_ENV_DEV }}

.github/workflows/deploy-prod.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@ jobs:
1919
with:
2020
aws_role_arn: ${{ vars.AWS_ROLE_ARN_PROD }}
2121
env: prod
22-
secrets:
23-
env_file: ${{ secrets.ENV_PROD }}
24-
cdk_env_file: ${{ secrets.CDK_ENV_PROD }}
22+
env_file: ${{ vars.ENV_PROD }}
23+
cdk_env_file: ${{ vars.CDK_ENV_PROD }}

.github/workflows/deploy-qa.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@ jobs:
1818
with:
1919
aws_role_arn: ${{ vars.AWS_ROLE_ARN_QA }}
2020
env: qa
21-
secrets:
22-
env_file: ${{ secrets.ENV_QA }}
23-
cdk_env_file: ${{ secrets.CDK_ENV_QA }}
21+
env_file: ${{ vars.ENV_QA }}
22+
cdk_env_file: ${{ vars.CDK_ENV_QA }}

.github/workflows/reusable-deploy.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ on:
44
workflow_call:
55
inputs:
66
aws_region:
7-
required: false
87
type: string
8+
required: false
99
default: 'us-east-1'
1010
aws_role_arn:
11-
required: true
1211
type: string
12+
required: true
1313
env:
14-
required: false
1514
type: string
15+
required: false
1616
default: 'dev'
17-
secrets:
1817
env_file:
18+
type: string
1919
required: true
2020
cdk_env_file:
21+
type: string
2122
required: true
2223

2324
jobs:
@@ -46,7 +47,7 @@ jobs:
4647

4748
- name: Create app .env file
4849
run: |
49-
echo "${{ secrets.env_file }}" > .env
50+
echo "${{ inputs.env_file }}" > .env
5051
echo "VITE_BUILD_DATE=$(date +'%Y-%m-%d')" >> .env
5152
echo "VITE_BUILD_TIME=$(date +'%H:%M:%S%z')" >> .env
5253
echo "VITE_BUILD_TS=$(date +'%Y-%m-%dT%H:%M:%S%z')" >> .env
@@ -76,7 +77,7 @@ jobs:
7677
- name: Create infrastructure .env file
7778
working-directory: ./infrastructure
7879
run: |
79-
echo "${{ secrets.cdk_env_file }}" > .env
80+
echo "${{ inputs.cdk_env_file }}" > .env
8081
echo "✅ Infrastructure .env file created"
8182
8283
- name: Build infrastructure

docs/DEVOPS_GUIDE.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,24 @@ The project uses GitHub Actions for CI/CD. Below is a detailed description of ea
3232
- **Concurrency:**
3333
- Ensures only one workflow runs per branch/ref at a time; cancels in-progress runs for the same branch/ref.
3434
- **Timeout:** 10 minutes
35+
- **Prerequisites:**
36+
- GitHub Actions variables must be configured:
37+
- `ENV_CI` - Application environment variables for CI
38+
- `CDK_ENV_DEV` - CDK infrastructure environment configuration for DEV
39+
- `AWS_ROLE_ARN_DEV` - AWS IAM Role ARN for development environment
40+
- `AWS_REGION` - AWS region for deployment
3541
- **Main Steps:**
3642
1. Checkout repository
3743
2. Setup Node.js (from `.nvmrc`, with npm cache)
3844
3. Install dependencies (`npm ci`)
39-
4. Create application `.env` file from secrets (`ENV_CI`)
45+
4. Create application `.env` file from variables (`ENV_CI`)
4046
5. Lint code (`npm run lint`)
4147
6. Check code formatting (`npm run format:check`)
4248
7. Build application (`npm run build`)
4349
8. Run unit tests with CI mode (`npm run test:ci`)
4450
9. Build Storybook (`npm run build:storybook`)
4551
10. Install and build infrastructure code
46-
11. Create infrastructure `.env` file from secrets (`CDK_ENV_DEV`)
52+
11. Create infrastructure `.env` file from variables (`CDK_ENV_DEV`)
4753
12. Configure AWS credentials using OIDC (role: `AWS_ROLE_ARN_DEV`)
4854
13. Synthesize CDK stacks (`npm run synth`)
4955
14. Clean up sensitive files (`.env`, `cdk.out`)
@@ -94,7 +100,6 @@ The project uses GitHub Actions for CI/CD. Below is a detailed description of ea
94100
- GitHub Actions variables must be configured:
95101
- `AWS_ROLE_ARN_DEV` - AWS IAM Role ARN for development environment
96102
- `AWS_REGION` - AWS region for deployment (default: `us-east-1`)
97-
- GitHub Actions secrets must be configured:
98103
- `ENV_DEV` - Application environment variables
99104
- `CDK_ENV_DEV` - CDK infrastructure environment configuration
100105
- **Execution:** Calls the reusable `Deploy` workflow
@@ -112,7 +117,6 @@ The project uses GitHub Actions for CI/CD. Below is a detailed description of ea
112117
- GitHub Actions variables must be configured:
113118
- `AWS_ROLE_ARN_QA` - AWS IAM Role ARN for QA environment
114119
- `AWS_REGION` - AWS region for deployment
115-
- GitHub Actions secrets must be configured:
116120
- `ENV_QA` - Application environment variables
117121
- `CDK_ENV_QA` - CDK infrastructure environment configuration
118122
- **Execution:** Calls the reusable `Deploy` workflow
@@ -130,7 +134,6 @@ The project uses GitHub Actions for CI/CD. Below is a detailed description of ea
130134
- GitHub Actions variables must be configured:
131135
- `AWS_ROLE_ARN_PROD` - AWS IAM Role ARN for production environment
132136
- `AWS_REGION` - AWS region for deployment
133-
- GitHub Actions secrets must be configured:
134137
- `ENV_PROD` - Application environment variables
135138
- `CDK_ENV_PROD` - CDK infrastructure environment configuration
136139
- **Execution:** Calls the reusable `Deploy` workflow
@@ -145,7 +148,6 @@ The project uses GitHub Actions for CI/CD. Below is a detailed description of ea
145148
- `aws_role_arn` - AWS IAM role ARN for the target environment (required)
146149
- `aws_region` - AWS region for deployment (default: `us-east-1`)
147150
- `env` - Environment name (dev, qa, prod; default: `dev`)
148-
- **Secrets:**
149151
- `env_file` - Application environment variables (required)
150152
- `cdk_env_file` - CDK infrastructure environment configuration (required)
151153
- **Timeout:** 30 minutes
@@ -195,11 +197,6 @@ GitHub Actions variables should be configured in the repository settings:
195197
- `AWS_ROLE_ARN_DEV` - AWS IAM role ARN for development
196198
- `AWS_ROLE_ARN_QA` - AWS IAM role ARN for QA
197199
- `AWS_ROLE_ARN_PROD` - AWS IAM role ARN for production
198-
199-
### Secrets
200-
201-
GitHub Actions secrets should be configured in the repository settings:
202-
203200
- `ENV_CI` - Environment variables for CI workflow (application)
204201
- `ENV_DEV` - Environment variables for DEV deployment (application)
205202
- `ENV_QA` - Environment variables for QA deployment (application)

infrastructure/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infrastructure/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-starter-infrastructure",
3-
"version": "1.0.0",
3+
"version": "1.1.0-alhpa.1",
44
"private": true,
55
"scripts": {
66
"build": "tsc",

package-lock.json

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)