-
Notifications
You must be signed in to change notification settings - Fork 5
93 lines (75 loc) · 2.74 KB
/
deploy.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
88
89
90
91
92
93
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Deploy
on:
push:
branches: [ main ]
permissions:
id-token: write # required to use OIDC authentication
contents: read # required to checkout the code from the repo
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout 📥
uses: actions/checkout@v2
- name: Use Node.js 20.12.0 ⚙️
uses: actions/setup-node@v1
with:
node-version: 20.12.0
- name: Setup vars 📋
id: vars
run: |
echo ::set-output name=distdir::$(git rev-parse --short ${{ github.sha }})-20.x-dist
- name: Install 🎯
run: cd site; npm install
- name: Build 🏃
run: cd site; npm run build
- name: Upload artifacts 📤
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: site/dist
if-no-files-found: error
deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout 📥
uses: actions/checkout@v2
- name: Download artifacts 📥
uses: actions/download-artifact@v2
with:
name: build-artifacts
path: site/dist
- name: Configure AWS credentials 🔐
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: arn:aws:iam::851725248912:role/aria-cicd-role
role-duration-seconds: 900 # the ttl of the session, in seconds.
aws-region: us-west-2
- name: Setup vars 📋
id: vars
run: |
echo ::set-output name=identifier::$(git rev-parse --short ${{ github.sha }})-20.x
echo ::set-output name=distdir::$(git rev-parse --short ${{ github.sha }})-20.x-dist
- name: Prep files 🔨
run: cd site ; npm run aws_deploy
env:
IDENTIFIER: ${{ steps.vars.outputs.identifier }}
DISTDIR: ${{ steps.vars.outputs.distdir }}
- name: Copy new index file to S3 📤
run: aws s3 cp site/$DISTDIR/index.html s3://aria-site/aria/$IDENTIFIER-aria.html --no-progress
env:
IDENTIFIER: ${{ steps.vars.outputs.identifier }}
DISTDIR: ${{ steps.vars.outputs.distdir }}
- name: Copy new dist dir to S3 📤
run: aws s3 cp site/$DISTDIR s3://aria-site/aria/$DISTDIR --recursive --no-progress
env:
IDENTIFIER: ${{ steps.vars.outputs.identifier }}
DISTDIR: ${{ steps.vars.outputs.distdir }}
- name: Deployment complete! 🚀
run: |
echo "Your build is at: https://d13285jxgcxetl.cloudfront.net/aria/${{ steps.vars.outputs.distdir }}/index.html"