Feat/update 20240105 (#42) #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] | |
on: | |
push: | |
branches: | |
- master | |
- release/dev | |
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@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 Production | |
uses: aws-actions/configure-aws-credentials@v2 | |
if: ${{ github.ref == 'refs/heads/master' }} | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
role-duration-seconds: 1800 | |
- 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: Build And Deploy | |
if: ${{ github.ref == 'refs/heads/master' }} | |
run: | | |
ACCOUNT_NAME=$(aws ssm get-parameter --name /foundation/account/name --query 'Parameter.Value' --output text) | |
echo $ACCOUNT_NAME | |
STACK_NAME=jonessite | |
BUCKET=$(aws cloudformation --region us-east-1 describe-stacks --stack-name ${STACK_NAME} --query 'Stacks[0].Outputs[?OutputKey==`outputbucket`].OutputValue' --output text) | |
echo $BUCKET | |
npm install | |
npm run build | |
aws s3 sync ./build s3://${BUCKET}/ --delete | |
#aws s3 cp build/index.html s3://${BUCKET}/index.html --metadata-directive REPLACE --cache-control no-cache,no-store,max-age=0 | |
- name: Build And Deploy in Test | |
if: ${{ github.ref == 'refs/heads/release/dev' }} | |
run: | | |
echo "Try Me" | |
aws sts get-caller-identity | |
echo "again" | |
ACCOUNT_NAME=$(aws ssm get-parameter --name /foundation/account/name --query 'Parameter.Value' --output text) | |
echo $ACCOUNT_NAME | |
STACK_NAME=mccsbx-jonessite | |
BUCKET=$(aws cloudformation --region us-east-1 describe-stacks --stack-name ${STACK_NAME} --query 'Stacks[0].Outputs[?OutputKey==`outputbucket`].OutputValue' --output text) | |
echo $BUCKET | |
npm install | |
npm run build | |
aws s3 sync ./build s3://${BUCKET}/ --delete | |
#aws s3 cp build/index.html s3://${BUCKET}/index.html --metadata-directive REPLACE --cache-control no-cache,no-store,max-age=0 | |