Skip to content

Commit 10b398d

Browse files
maellehadley
andauthored
Let Netlify post preview URL again (#2489)
And keep github pages and netlify workflows separate to hopefully avoid problems in the future. --------- Co-authored-by: Hadley Wickham <[email protected]>
1 parent 2239e64 commit 10b398d

File tree

2 files changed

+62
-43
lines changed

2 files changed

+62
-43
lines changed

.github/workflows/netlify.yaml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
on:
2+
pull_request:
3+
branches: [main, master]
4+
5+
name: pkgdown-pr
6+
7+
jobs:
8+
netlify:
9+
runs-on: ubuntu-latest
10+
env:
11+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- uses: r-lib/actions/setup-tinytex@v2
16+
17+
- uses: r-lib/actions/setup-pandoc@v2
18+
19+
- uses: r-lib/actions/setup-r@v2
20+
with:
21+
use-public-rspm: true
22+
23+
- uses: r-lib/actions/setup-r-dependencies@v2
24+
with:
25+
extra-packages: any::pkgdown, local::.
26+
needs: website
27+
28+
- name: Install package
29+
run: R CMD INSTALL .
30+
31+
- name: Create website
32+
run: |
33+
pkgdown::build_site()
34+
shell: Rscript {0}
35+
36+
- name: Create index file
37+
run: |
38+
echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0;URL=/dev/index.html" /> <script language="javascript"> window.location.replace('/dev/index.html')</script></head></html>' > ./docs/index.html
39+
40+
- name: Deploy to Netlify
41+
uses: nwtgck/[email protected]
42+
with:
43+
publish-dir: './docs'
44+
production-branch: main
45+
github-token: ${{ secrets.GITHUB_TOKEN }}
46+
deploy-message:
47+
'Deploy from GHA: ${{ github.event.pull_request.title || github.event.head_commit.message }} (${{ github.sha }})'
48+
# these default to 'true'
49+
enable-commit-comment: false
50+
enable-github-deployment: false
51+
env:
52+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
53+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

.github/workflows/pkgdown.yaml

+9-43
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
on:
44
push:
55
branches: [main, master]
6-
pull_request:
7-
branches: [main, master]
86
release:
97
types: [published]
108
workflow_dispatch:
@@ -13,22 +11,16 @@ name: pkgdown
1311

1412
jobs:
1513
pkgdown:
16-
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork == false
1714
runs-on: ubuntu-latest
1815
# Only restrict concurrency for non-PR jobs
1916
concurrency:
2017
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
2118
env:
2219
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
23-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
24-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
25-
isPush: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
2620
permissions:
2721
contents: write
2822
steps:
29-
- uses: actions/checkout@v3
30-
31-
- uses: r-lib/actions/setup-tinytex@v2
23+
- uses: actions/checkout@v4
3224

3325
- uses: r-lib/actions/setup-pandoc@v2
3426

@@ -41,40 +33,14 @@ jobs:
4133
extra-packages: any::pkgdown, local::.
4234
needs: website
4335

44-
- name: Install package
45-
run: R CMD INSTALL .
46-
47-
- name: Build and deploy pkgdown site
48-
if: contains(env.isPush, 'true')
49-
run: |
50-
git config --local user.name "$GITHUB_ACTOR"
51-
git config --local user.email "[email protected]"
52-
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
53-
54-
- name: Create website
55-
if: contains(env.isPush, 'false')
56-
run: |
57-
pkgdown::build_site()
36+
- name: Build site
37+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
5838
shell: Rscript {0}
5939

60-
- name: Create index file
61-
if: contains(env.isPush, 'false')
62-
run: |
63-
echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0;URL=/dev/index.html" /> <script language="javascript"> window.location.replace('/dev/index.html')</script></head></html>' > ./docs/index.html
64-
65-
- name: Deploy to Netlify
66-
if: contains(env.isPush, 'false')
67-
id: netlify-deploy
68-
uses: nwtgck/[email protected]
40+
- name: Deploy to GitHub pages 🚀
41+
if: github.event_name != 'pull_request'
42+
uses: JamesIves/[email protected]
6943
with:
70-
publish-dir: './docs'
71-
production-branch: master
72-
github-token: ${{ secrets.GITHUB_TOKEN }}
73-
deploy-message:
74-
'Deploy from GHA: ${{ github.event.pull_request.title || github.event.head_commit.message }} (${{ github.sha }})'
75-
# these all default to 'true'
76-
enable-pull-request-comment: false
77-
enable-commit-comment: false
78-
# enable-commit-status: true
79-
# overwrites-pull-request-comment: true
80-
timeout-minutes: 1
44+
clean: false
45+
branch: gh-pages
46+
folder: docs

0 commit comments

Comments
 (0)