Skip to content

Deploy Patterns to Amazon S3 #1

Deploy Patterns to Amazon S3

Deploy Patterns to Amazon S3 #1

Workflow file for this run

name: "Deploy Patterns to Amazon S3"
on:
workflow_dispatch:
push:
branches: # we can add branches to this list which will deploy code to Acquia GitLab as we push code to those branches.
# - develop
# - production
- dummy
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOIT_WEBHOOK_URL }} # for slack
NODE_VERSION: 14
TZ: "America/New_York"
jobs:
Deploy:
# installed software: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2004-Readme.md
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
# checkout the cob repository that has been pushed to.
- name: Set Variables
run: |
if [[ "{{ branch }}" == "develop" ]]; then
echo "BUCKET_NAME=patterns-stg.boston.gov" >> "${GITHUB_ENV}"
elif [[ "{{ branch }}" == "production" ]]; then
echo "BUCKET_NAME=patterns.boston.gov" >> "${GITHUB_ENV}"
else
echo "BUCKET_NAME=patterns-uat.boston.gov" >> "${GITHUB_ENV}"
fi
if [[ {{ env.S3_DRY_RUN }} == 1 ]];then
echo "S3_DEST_DIR='/'" >> "${GITHUB_ENV}"
else
echo "S3_DEST_DIR='/DRY_RUN/'" >> "${GITHUB_ENV}"
fi
- name: Checkout the repository
uses: actions/checkout@v4
- name: Downgrade node 14
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Build the public folder
id: Build patterns and CDN assets

Check failure on line 49 in .github/workflows/deploy_to_s3.yml

View workflow run for this annotation

GitHub Actions / Deploy Patterns to Amazon S3

Invalid workflow file

The workflow is not valid. .github/workflows/deploy_to_s3.yml (Line: 49, Col: 13): The identifier 'Build patterns and CDN assets' is invalid. IDs may only contain alphanumeric characters, '_', and '-'. IDs must start with a letter or '_' and and must be less than 100 characters. .github/workflows/deploy_to_s3.yml (Line: 71, Col: 13): The identifier 'Deploy to Amazon' is invalid. IDs may only contain alphanumeric characters, '_', and '-'. IDs must start with a letter or '_' and and must be less than 100 characters.
run: |
npm install
npm run build
- name: Printout vars
if: ${{ vars.DEPLOY_DEBUG == 1 }}
run: |
du
- name: Run Percy Tests
if: ${{ vars.RUN_PERCY == 1 }}
run: |
gem install faraday -v 1.8.0
percy snapshot public --snapshots_regex="(components\/preview.).*\.html$" --enable_javascript --trace --widths "375,1280"
- name: Run Jest Tests
if: ${{ vars.RUN_JEST == 1 }}
run: |
npm run jest.ci
- name: Upload to Amazon
id: Deploy to Amazon
uses: jakejarvis/[email protected]
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ env.BUCKET_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-2'
SOURCE_DIR: 'public'
DEST_DIR: ${{ env.S3_DEST_DIR }}
- name: Invalidate AWS CloudFront
id: Invalidate Cache
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
PATHS: "/*"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DEBUG: ${{ env.DEPLOY_DEBUG }}
- name: Post to Slack - success
uses: act10ns/[email protected]
if: ${{ success() }}
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ vars.SLACK_MONITORING_CHANNEL }}
- name: Post to Slack - failure
uses: act10ns/[email protected]
if: ${{ failure() }}
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: ${{ vars.SLACK_MONITORING_CHANNEL }}