remove frontend PR artifacts from S3 (#665)

* adds initial prefix

* adds steps

* adds names

* adds runs-on

* tests direct env

* add prefix to folder

* rm AWS

* adds s3 uri

* adds recursive

* removes slash

* Trigger Build

* Trigger Build

* remove recursive

* update GHA name

* adds slash to s3 uri

* Trigger Build

* adds ls

* Trigger Build

* Trigger Build

* Trigger Build

* list main s3 bucket

* Trigger Build

* list j4-tool dir

* Trigger Build

* Trigger Build

* Add rm cmd

* adds CDN as env var

* modify web cdn id

* update cdn id

* Trigger Build

* Remove artifacts on PR merge

- also make the web cdn an env variable

* make web CDN an env variable

* Update CDN ID to newest CDN

* Add test remove artifacts yml file

* Add jobs to test.yml

* Update PR number to 111

* Remove testing artifacts yaml file
This commit is contained in:
Vim 2021-10-07 20:38:37 -04:00 committed by GitHub
commit b913cf21e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -8,6 +8,9 @@ on:
branches: [main]
paths:
- "client/**/*"
env:
PR_NUMBER: ${{github.event.pull_request.number}}
WEB_CDN_ID: E27WCOZZ03KIBX
jobs:
build:
runs-on: ubuntu-latest
@ -79,11 +82,13 @@ jobs:
- name: Invalidate cache on AWS CDNs
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: "ED03LPVC4OXSW" # TODO: update to new CDN after access is provided
DISTRIBUTION: ${{env.WEB_CDN_ID}}
PATHS: "/*"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
- name: Remove staging artifacts
run: aws s3 rm s3://usds-geoplatform-justice40-website/justice40-tool/ --exclude "*" --include "$(echo $PR_NUMBER)-*" --recursive
- name: Update PR with deployed URL
uses: mshick/add-pr-comment@v1
with:

View file

@ -7,6 +7,8 @@ on:
branches: [main]
paths:
- "client/**/*"
env:
PR_NUMBER: ${{github.event.pull_request.number}}
jobs:
build:
runs-on: ubuntu-latest
@ -24,7 +26,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Set DESTINATION_FOLDER for branch
run: |
echo "DESTINATION_FOLDER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
- name: Install
run: npm ci
- name: Build
@ -66,7 +68,7 @@ jobs:
path: ./public
- name: Set DESTINATION_FOLDER for branch
run: |
echo "DESTINATION_FOLDER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@4.1.0
with: