-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (72 loc) · 2.29 KB
/
deploy-docs-aws.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Deploy docs to AWS
on:
workflow_dispatch:
inputs:
tag:
description: "Git tag to deploy"
required: true
default: "last-release"
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:
ref: ${{ github.event.inputs.tag }}
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