Skip to content

Commit

Permalink
Refines Github deploy action
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrkupton committed May 2, 2024
1 parent e83b753 commit dd386ef
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion .github/workflows/deploy_to_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:
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
Expand All @@ -41,6 +46,7 @@ jobs:
cache: 'npm'

- name: Build the public folder
id: Build patterns and CDN assets
run: |
npm install
npm run build
Expand All @@ -51,15 +57,18 @@ jobs:
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
Expand All @@ -69,12 +78,31 @@ jobs:
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 }}
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 }}

0 comments on commit dd386ef

Please sign in to comment.