Skip to content

Merge pull request #90 from mcliff1/feat/node20 #147

Merge pull request #90 from mcliff1/feat/node20

Merge pull request #90 from mcliff1/feat/node20 #147

Workflow file for this run

# 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: [16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
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@v2
# https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions
- name: Configuration for Test
uses: aws-actions/configure-aws-credentials@v1
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@v1
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: |
ACCOUNT_NAME=$(aws ssm get-parameter --name /foundation/account/name --query 'Parameter.Value' --output text)
echo $ACCOUNT_NAME
echo "Current image has Node 16 installed"
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' }}