CI/CD

WARNING

Neither CDK nor Winglang work with pnpm currently.

Github Actions with AWS SSO

This involves setting up a workflow using security token service (STS) to assume a role. Here is an article on how to do this: github-actions-with-aws-sso

The workflow for this blog looks like this:

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  AWS_REGION: "us-east-1"

permissions:
  id-token: write
  contents: read

jobs:
  AssumeRoleAndCDKDeploy:
    runs-on: ubuntu-latest
    steps:
      - name: Git clone the repository
        uses: actions/checkout@v3

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: "18"
          cache: "npm"

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1.7.0
        with:
          role-to-assume: arn:aws:iam::851725517932:role/AdministratorAccess
          role-session-name: GitHub_to_AWS_via_FederatedOIDC
          aws-region: ${{ env.AWS_REGION }}

      - name: Sts GetCallerIdentity
        run: aws sts get-caller-identity

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

      - name: Install root project dependencies
        run: npm ci

      - name: Build documentation
        run: npm run build # Adjust this command based on your actual build script

      - name: List contents of doc_build
        run: ls -R ./doc_build

      - name: Install CDK project dependencies
        run: |
          cd ./blog-app-examples/cdk-static-hosting
          npm ci

      - name: Build CDK project
        run: |
          cd ./blog-app-examples/cdk-static-hosting
          npm run build

      - name: CDK Deploy
        run: |
          cd ./blog-app-examples/cdk-static-hosting
          cdk deploy --all --require-approval never
        env:
          AWS_REGION: ${{ env.AWS_REGION }}

Dynamic Hosting

workflow for dynamic hosting (at ssr subdomain) ssr.bronifty.xyz

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  AWS_REGION: "us-east-1"

permissions:
  id-token: write
  contents: read

jobs:
  AssumeRoleAndCDKDeploy:
    runs-on: ubuntu-latest
    steps:
      - name: Git clone the repository
        uses: actions/checkout@v3

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: "20"
          cache: "npm"

      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1.7.0
        with:
          role-to-assume: arn:aws:iam::851725517932:role/AdministratorAccess
          role-session-name: GitHub_to_AWS_via_FederatedOIDC
          aws-region: ${{ env.AWS_REGION }}

      - name: Set AWS account ID
        run: echo "AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)" >> $GITHUB_ENV

      - name: Sts GetCallerIdentity
        run: aws sts get-caller-identity

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

      - name: Install root project dependencies
        run: npm ci

      - name: Build and zip SSR application
        run: |
          cd ./blog-app-examples/remix-lambda
          npm install
          npm run build
          npm run zip

      - name: List contents of build directory
        run: ls -R ./blog-app-examples/remix-lambda/build

      - name: Install CDK project dependencies
        run: |
          cd ./blog-app-examples/cdk-dynamic-hosting
          npm ci

      - name: Build CDK project
        run: |
          cd ./blog-app-examples/cdk-dynamic-hosting
          npm run build

      - name: CDK Deploy
        run: |
          cd ./blog-app-examples/cdk-dynamic-hosting
          cdk deploy --all --require-approval never
        env:
          AWS_REGION: ${{ env.AWS_REGION }}
          AWS_ACCOUNT_ID: ${{ env.AWS_ACCOUNT_ID }}