-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (67 loc) · 2.57 KB
/
s3-publish.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
# this workflow will publish to an AWS S3 Bucket
#
# based off branch we will look up and gain credentials from the environment
# DEPLOY_{env}_KEY, SECRET, ROLE
#
# ref: https://github.com/mcliff1/cliffconsulting/new/master?filename=.github%2Fworkflows%2Faws.yml&workflow_template=aws
name: AWS Publish
on:
pull_request:
branches:
- master
- release/dev
#push:
# - feature/*
#on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions
- name: Configuration for Test
uses: aws-actions/configure-aws-credentials@v2
if: ${{ github.ref == 'refs/heads/release/dev' }}
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.TEST_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
role-to-assume: ${{ secrets.TEST_AWS_ROLE_ARN }}
role-duration-seconds: 1800
- name: Configuration for Production
uses: aws-actions/configure-aws-credentials@v2
if: ${{ github.ref == 'refs/heads/master' }}
with:
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
role-to-assume: ${{ secrets.PROD_AWS_ROLE_ARN }}
role-duration-seconds: 1800
- name: Build And Deploy
run: |
nodejs -v
ACCOUNT_NAME=$(aws ssm get-parameter --name /foundation/account/name --query 'Parameter.Value' --output text)
echo $ACCOUNT_NAME
BUCKET=$(aws ssm get-parameter --name /app/cdn/${ACCOUNT_NAME}-cliffconsulting/bucket --query 'Parameter.Value' --output text)
echo $BUCKET
npm install
npm run build
aws s3 sync ./build s3://${BUCKET}/ --delete
if: ${{ github.ref == 'refs/heads/release/dev' || github.ref == 'refs/heads/master' }}