Add to team #36
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: PR Preview Workflow | |
on: | |
pull_request_target: | |
types: [opened, synchronize, closed] | |
jobs: | |
build-and-preview: | |
if: github.event.action == 'opened' || github.event.action == 'synchronize' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up Quarto | |
uses: quarto-dev/quarto-actions/setup@v2 | |
- run: quarto --version | |
- name: Render Quarto site | |
run: quarto render | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: _site | |
target-folder: pr-previews/${{ github.event.pull_request.number }} | |
clean: false | |
commit-message: Deploy preview for PR ${{ github.event.pull_request.number }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
comment-preview-url: | |
needs: build-and-preview | |
if: needs.build-and-preview.result == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Comment Preview URL | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
<!-- preview-url-comment --> | |
Preview the changes: https://turinglang.org/pr-previews/${{ github.event.pull_request.number }} | |
Please avoid using the search feature and navigation bar in PR previews! | |
comment_tag: preview-url-comment | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
delete-preview-directory: | |
if: github.event.action == 'closed' || github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout gh-pages branch | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
- name: Remove PR Preview Directory | |
run: | | |
PR_NUMBER=${{ github.event.pull_request.number }} | |
PREVIEW_DIR="pr-previews/${PR_NUMBER}" | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git pull origin gh-pages | |
rm -rf ${PREVIEW_DIR} | |
git add . | |
git commit -m "Remove preview for merged PR #${PR_NUMBER}" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |