revite/.github/workflows/preview_pull_request.yml

53 lines
1.9 KiB
YAML
Raw Normal View History

2021-09-10 14:48:48 -04:00
name: Preview Pull Request
#! 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:
pull_request_target:
2021-09-10 14:48:48 -04:00
types: [synchronize, reopened, labeled]
jobs:
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')
env:
BASE: refs/pull/${{ github.event.pull_request.number }}/merge
REPO: ${{ github.event.repository.name }}
2021-09-10 14:48:48 -04:00
steps:
- 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 }}
path: pull
2021-09-10 14:48:48 -04:00
submodules: recursive
- name: build
2021-09-14 00:51:27 -04:00
uses: ./.github/actions/build
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:
2021-09-14 01:48:28 -04:00
folder: pull/dist
2021-09-11 10:12:14 -04:00
branch: build-previews
target-folder: ${{ env.BASE }}
2021-09-11 10:12:14 -04:00
single-commit: true
2021-09-16 16:38:18 -04:00
commit-message: "Publishing build result from #${{ github.event.pull_request.number }}"
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
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.