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: