Skip to content

Commit

Permalink
Add dev CD
Browse files Browse the repository at this point in the history
  • Loading branch information
zacdezgeo committed Oct 11, 2024
1 parent 59905e9 commit 965fefe
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Deploy Space2Stats API Staging

on:
pull_request:
branches:
- main # Trigger on PRs targeting the main branch

permissions:
id-token: write
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16' # Ensure compatibility with CDK

- name: Install AWS CDK
run: npm install -g aws-cdk

- name: Install dependencies
run: npm install

- name: Build code
run: npm run build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::017820688988:role/Space2Stats-Staging-Deploy-Role # Staging-specific IAM role
aws-region: ${{ env.CDK_DEFAULT_REGION }}

- name: Bootstrap CDK (if not done yet)
run: cdk bootstrap aws://${{ env.CDK_DEFAULT_ACCOUNT }}/${{ env.CDK_DEFAULT_REGION }}

- name: Deploy CDK stack to staging
env:
STAGE: dev
CDK_CERTIFICATE_ARN: ${{ env.STAGING_CDK_CERTIFICATE_ARN }} # Staging-specific certificate
CDK_DEFAULT_ACCOUNT: ${{ env.STAGING_CDK_DEFAULT_ACCOUNT }} # Staging-specific AWS account
CDK_DEFAULT_REGION: ${{ env.CDK_DEFAULT_REGION }}
CDK_DOMAIN_NAME: ${{ env.STAGING_CDK_DOMAIN_NAME }} # Staging-specific domain
run: cdk deploy --require-approval never
1 change: 1 addition & 0 deletions .github/workflows/cd.yml → .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:

- name: Deploy CDK stack
env:
STAGING: prod
CDK_CERTIFICATE_ARN: ${{ env.CDK_CERTIFICATE_ARN }}
CDK_DEFAULT_ACCOUNT: ${{ env.CDK_DEFAULT_ACCOUNT }}
CDK_DEFAULT_REGION: ${{ env.CDK_DEFAULT_REGION }}
Expand Down

0 comments on commit 965fefe

Please sign in to comment.