-
Notifications
You must be signed in to change notification settings - Fork 17
88 lines (75 loc) · 2.38 KB
/
pr-preview.yml
File metadata and controls
88 lines (75 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: PR Preview
# Builds and deploys a preview of the blog site for every PR targeting main.
on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
build-preview:
name: Build & Deploy PR Preview
runs-on: ubuntu-latest
container:
image: "ghcr.io/pharmaverse/docker_pharmaverse:4.5.1"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Configure Git safe directory
run: git config --global --add safe.directory /__w/blog/blog
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.9.12
- name: Install R Packages
run: |
R -e "install.packages(c(
'admiral',
'diffdf',
'patchwork',
'here',
'filters',
'janitor',
'link',
'sessioninfo',
'renv',
'riskmetric',
'sdtm.oak',
'mirai',
'dverse',
'autoslider.core'))"
- name: Install tinytex
run: quarto install tool tinytex
- name: Sanitize branch name for use as directory/URL slug
id: branch
run: |
SAFE_BRANCH=$(echo "${{ github.head_ref }}" | sed 's|[^a-zA-Z0-9._-]|-|g')
echo "safe=${SAFE_BRANCH}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Render Quarto Project
uses: quarto-dev/quarto-actions/render@v2
with:
to: html
- name: Publish PR preview to gh-pages subdirectory
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
destination_dir: ${{ steps.branch.outputs.safe }}
- name: Post preview URL comment on PR
uses: marocchino/sticky-pull-request-comment@v2
with:
header: "PR Preview"
message: |
:eyes: **Preview available!**
The preview website for this PR is available at:
https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ steps.branch.outputs.safe }}
_The preview is updated every time a new commit is pushed to this PR._
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}