From 0aa46935fbd1091d2592861c36a8c7be5803e923 Mon Sep 17 00:00:00 2001 From: Damien Ayers Date: Wed, 13 Mar 2024 16:12:55 +1100 Subject: [PATCH] Trial setup of PR Previews --- .github/workflows/deploy-pr-preview.yaml | 11 +++++------ deploy-pr-preview.sh | 7 ------- 2 files changed, 5 insertions(+), 13 deletions(-) delete mode 100755 deploy-pr-preview.sh diff --git a/.github/workflows/deploy-pr-preview.yaml b/.github/workflows/deploy-pr-preview.yaml index 49592a689..86947209d 100644 --- a/.github/workflows/deploy-pr-preview.yaml +++ b/.github/workflows/deploy-pr-preview.yaml @@ -11,6 +11,7 @@ on: env: PR_PREVIEW_SUBDOMAIN: pr-${{github.event.pull_request.number}}-preview DEPLOY_LOG_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + PR_PREVIEW_BUCKET: s3://khpreview.dea.ga.gov.au jobs: publish: @@ -48,7 +49,7 @@ jobs: - name: Configure AWS credentials via OIDC uses: aws-actions/configure-aws-credentials@v2 with: - role-to-assume: arn:aws:iam::538673716275:role/github-actions-dea-docs + role-to-assume: arn:aws:iam::538673716275:role/github-actions-dea-knowledge-hub-prs aws-region: ap-southeast-2 - name: "Comment on PR: Preview is building" @@ -64,10 +65,8 @@ jobs: | **Deploy log:** | [View the log]($DEPLOY_LOG_URL) | - name: Deploy site - env: - DISTRIBUTION_ID: ${{ secrets.DISTRIBUTION_ID }} - DEST_DIR: $PR_PREVIEW_SUBDOMAIN - run: ./deploy-pr-preview.sh + run: | + aws s3 sync --delete output "$PR_PREVIEW_BUCKET/$PR_PREVIEW_SUBDOMAIN" - name: "Update Comment on PR: Preview is ready" id: comment-preview-ready @@ -80,6 +79,6 @@ jobs: | | | | --- | --- | - | **Preview site:** | [$PR_PREVIEW_SUBDOMAIN.knowledge.dea.ga.gov.au](https://$PR_PREVIEW_SUBDOMAIN.knowledge.dea.ga.gov.au/) | + | **Preview site:** | [$PR_PREVIEW_SUBDOMAIN.khpreview.dea.ga.gov.au](https://$PR_PREVIEW_SUBDOMAIN.khpreview.dea.ga.gov.au/) | | **Deploy log:** | [View the log]($DEPLOY_LOG_URL) | diff --git a/deploy-pr-preview.sh b/deploy-pr-preview.sh deleted file mode 100755 index 13e06658f..000000000 --- a/deploy-pr-preview.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# Deploy to S3 and invalidate the CloudFront distribution - -python -m pip install awscli -aws s3 sync --delete output s3://docs.dea.ga.gov.au -aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*'