2021-09-10 14:48:48 -04:00
|
|
|
name: Preview Pull Request
|
|
|
|
|
2021-09-13 23:54:39 -04:00
|
|
|
#! Safety:
|
|
|
|
#! this workflow should not execute any untrusted input at all
|
|
|
|
#! see the docs on `pull_request_target` for more
|
2021-09-10 14:48:48 -04:00
|
|
|
on:
|
2021-09-13 23:54:39 -04:00
|
|
|
pull_request_target:
|
2021-09-10 14:48:48 -04:00
|
|
|
types: [synchronize, reopened, labeled]
|
|
|
|
|
|
|
|
jobs:
|
2021-09-13 23:54:39 -04:00
|
|
|
preview:
|
2021-09-10 14:48:48 -04:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
# make sure the pull request is labeled with 'use-preview'
|
|
|
|
if: github.event.label.name == 'use-preview' || contains(github.event.pull_request.labels.*.name, 'use-preview')
|
2021-09-13 23:54:39 -04:00
|
|
|
env:
|
|
|
|
BASE: refs/pull/${{ github.event.pull_request.number }}/merge
|
|
|
|
REPO: ${{ github.event.repository.name }}
|
2021-09-10 14:48:48 -04:00
|
|
|
|
|
|
|
steps:
|
2021-09-13 23:54:39 -04:00
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
2021-09-10 14:48:48 -04:00
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
# Head commit of the pull request
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
2021-09-13 23:54:39 -04:00
|
|
|
path: pull
|
2021-09-10 14:48:48 -04:00
|
|
|
submodules: recursive
|
|
|
|
|
|
|
|
- name: build
|
2021-09-13 23:54:39 -04:00
|
|
|
uses: ./.github/actions/build_preview
|
|
|
|
with:
|
|
|
|
base: /${{ env.REPO }}/${{ env.BASE }}/
|
|
|
|
folder: pull
|
2021-09-10 14:48:48 -04:00
|
|
|
|
|
|
|
- name: publish preview
|
|
|
|
uses: JamesIves/github-pages-deploy-action@4.1.5
|
|
|
|
with:
|
|
|
|
folder: dist
|
2021-09-11 10:12:14 -04:00
|
|
|
branch: build-previews
|
2021-09-13 23:54:39 -04:00
|
|
|
target-folder: ${{ env.BASE }}
|
2021-09-11 10:12:14 -04:00
|
|
|
single-commit: true
|
2021-09-10 14:48:48 -04:00
|
|
|
|
|
|
|
- name: send comment
|
|
|
|
uses: marocchino/sticky-pull-request-comment@v2
|
|
|
|
with:
|
|
|
|
header: Preview environment
|
|
|
|
message: |
|
|
|
|
## Preview environment
|
2021-09-13 23:54:39 -04:00
|
|
|
https://${{ github.repository_owner }}.github.io/${{ env.REPO }}/${{ env.BASE }}/
|
2021-09-10 14:48:48 -04:00
|
|
|
|
|
|
|
This link will remain active until the `use-preview` label is removed.
|