-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (72 loc) · 2.63 KB
/
deploy-dev.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
86
87
name: Deploy to Development
on:
push:
branches:
- main
tags:
- dev
concurrency:
group: ${{ github.workflow }}
env:
APP_NAME: ionic8-playground.leanstacks.net
AWS_CFN_STACK_NAME: ls-ui-ionic8playground-resources-dev
AWS_CFN_TEMPLATE: template.yml
AWS_ENV_CODE: dev
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_ROLE_ARN: ${{ vars.AWS_ROLE_ARN_DEV }}
ENV_FILE: ${{ secrets.ENV_DEV }}
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js Environment
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install Dependencies
run: npm ci
- name: Create Environment Configuration
run: |
echo "${{ env.ENV_FILE }}" > .env
echo "VITE_BUILD_DATE=$(date +'%Y-%m-%d')" >> .env
echo "VITE_BUILD_TIME=$(date +'%H:%M:%S%z')" >> .env
echo "VITE_BUILD_TS=$(date +'%Y-%m-%dT%H:%M:%S%z')" >> .env
echo "VITE_BUILD_COMMIT_SHA=${{ github.sha }}" >> .env
echo "VITE_BUILD_ENV_CODE=${{ env.AWS_ENV_CODE }}" >> .env
echo "VITE_BUILD_WORKFLOW_NAME=${{ github.workflow }}" >> .env
echo "VITE_BUILD_WORKFLOW_RUN_NUMBER=${{ github.run_number }}" >> .env
echo "VITE_BUILD_WORKFLOW_RUN_ATTEMPT=${{ github.run_attempt }}" >> .env
- name: Build
run: npm run build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: Deploy AWS CloudFormation Stack
run: |-
aws cloudformation deploy \
--stack-name ${{ env.AWS_CFN_STACK_NAME }} \
--template-file ${{ env.AWS_CFN_TEMPLATE }} \
--parameter-overrides EnvironmentCode=${{ env.AWS_ENV_CODE }} \
--tags App=${{ env.APP_NAME }} Env=${{ env.AWS_ENV_CODE }} OU=leanstacks Owner='Matthew Warman'
- name: Get CloudFormation Stack Outputs
id: cloudformation
run: |-
APP_BUCKET_NAME=$(
aws cloudformation describe-stacks \
--stack-name ${{ env.AWS_CFN_STACK_NAME }} \
--query "Stacks[0].Outputs[?OutputKey=='AppBucketName'].OutputValue | [0]"
)
echo "APP_BUCKET_NAME=$APP_BUCKET_NAME" >> "$GITHUB_OUTPUT"
- name: Deploy to AWS S3
run: |
aws s3 sync dist s3://${{ steps.cloudformation.outputs.APP_BUCKET_NAME }} --delete