From b913cf21e671d169ca9880b74522080f5f602a28 Mon Sep 17 00:00:00 2001 From: Vim <86254807+vim-usds@users.noreply.github.com> Date: Thu, 7 Oct 2021 20:38:37 -0400 Subject: [PATCH] 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 --- .github/workflows/deploy_main.yml | 7 ++++++- .github/workflows/deploy_staging.yml | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy_main.yml b/.github/workflows/deploy_main.yml index 4c25b1a4..991f2574 100644 --- a/.github/workflows/deploy_main.yml +++ b/.github/workflows/deploy_main.yml @@ -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: diff --git a/.github/workflows/deploy_staging.yml b/.github/workflows/deploy_staging.yml index 258beec7..836fdd60 100644 --- a/.github/workflows/deploy_staging.yml +++ b/.github/workflows/deploy_staging.yml @@ -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: