PR Preview GitHub Action [skip ci] #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to PR Preview | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- reopened | |
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: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.11"] | |
node-version: [18.x] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Pull latest from submodules | |
run: git submodule foreach git pull origin stable | |
# This doesn't update the submodule to the latest commit on the origin; therefore, you should manually do this on a semi-regular basis. | |
- name: Install Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install requirements | |
run: ./install-dependencies.sh | |
- name: Build site | |
env: | |
BUILD_MODE: demo | |
DEPLOY_NAME: Pull Request | |
run: ./build-pr-preview.sh | |
- 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-knowledge-hub-prs | |
aws-region: ap-southeast-2 | |
- name: "Comment on PR: Preview is building" | |
id: comment-preview-building | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{github.event.pull_request.number}} | |
body: | | |
## Preview is building ... | |
| <!-- --> | <!-- --> | | |
| --- | --- | | |
| **Deploy log:** | [View the log]($DEPLOY_LOG_URL) | | |
- name: Deploy site | |
run: | | |
aws s3 sync --delete output "$PR_PREVIEW_BUCKET/$PR_PREVIEW_SUBDOMAIN" | |
- name: "Update Comment on PR: Preview is ready" | |
id: comment-preview-ready | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{github.event.pull_request.number}} | |
comment-id: ${{ steps.comment-preview-building.outputs.comment-id }} | |
body: | | |
## Preview is ready | |
| <!-- --> | <!-- --> | | |
| --- | --- | | |
| **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) | | |