Skip to content

Deploy docs to AWS

Deploy docs to AWS #17

name: Deploy docs to AWS
on:
workflow_dispatch:
inputs:
environment:
description: "Select deployment environment"
required: true
type: choice
options:
- staging
- uat
- prod
default: staging
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_PAT }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Set environment variable
run: echo "CONFIGURATION=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
- name: Build and test
run: |
corepack enable
pnpm install --frozen-lockfile --ignore-scripts
pnpm format:check
pnpm build
pnpm test
- name: Setup AWS Credentials
if: github.ref == 'refs/heads/main'
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Sign in to Amazon ECR
if: github.ref == 'refs/heads/main'
id: ecr-sign-in
uses: aws-actions/amazon-ecr-login@v2
- name: Set up Docker Buildx
if: github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3
- name: Build and push docker
if: github.ref == 'refs/heads/main'
env:
ECR_REGISTRY: ${{ steps.ecr-sign-in.outputs.registry }}
ECR_REPOSITORY: life-events-design-system
IMAGE_TAG: ${{ github.event.inputs.environment }}
run: |
pnpm ds:deploy
- name: Deploy to ECS
if: github.ref == 'refs/heads/main'
env:
CLUSTER_NAME: life-events-ecs
SERVICE_NAME: design-system-service
run: |
aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --force-new-deployment