Skip to content

Commit 30000c1

Browse files
Merge pull request #42 from miraisolutions/feature/32-revise-github-pages-deployment-workflow
Revise CI-CD workflow to rely on `actions/deploy-pages`
2 parents 65b8e26 + 331bd83 commit 30000c1

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

.github/workflows/site.yaml

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ on:
1010
# Allow manual runs from the Actions tab
1111
workflow_dispatch:
1212

13-
jobs:
14-
CI-CD:
15-
runs-on: ${{ matrix.config.os }}
13+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
14+
permissions:
15+
contents: read
16+
pages: write
17+
id-token: write
1618

17-
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
19+
jobs:
1820

19-
strategy:
20-
# We keep a matrix for convenience, but we would always want to run on one
21-
# single OS and R version
22-
matrix:
23-
config:
24-
- {os: ubuntu-latest, r: 'release'}
21+
# Build job
22+
build:
23+
name: CI
24+
runs-on: ubuntu-latest
2525

2626
env:
2727
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
@@ -31,12 +31,15 @@ jobs:
3131
- name: Checkout repo
3232
uses: actions/checkout@v3
3333

34+
- name: Setup Pages
35+
uses: actions/configure-pages@v4
36+
3437
- uses: r-lib/actions/setup-pandoc@v2
3538

3639
- name: Setup R
3740
uses: r-lib/actions/setup-r@v2
3841
with:
39-
r-version: ${{ matrix.config.r }}
42+
r-version: release
4043
use-public-rspm: true
4144

4245
- name: Install and cache dependencies
@@ -48,27 +51,33 @@ jobs:
4851
shell: Rscript {0}
4952

5053
- name: Upload built site artifact
51-
uses: actions/upload-artifact@v1
54+
uses: actions/upload-pages-artifact@v3
5255
with:
53-
name: site
5456
path: _book
5557

5658
- name: Test website
5759
uses: docker://klakegg/html-proofer:3.18.8
5860
with:
5961
args: _book
6062

63+
# Deployment job
64+
deploy:
65+
name: CD
66+
runs-on: ubuntu-latest
67+
needs: build
68+
if: github.ref == 'refs/heads/master'
69+
70+
# Allow one concurrent deployment
71+
concurrency:
72+
group: "pages" # fixed string ensures any execution of this job will share the same concurrency group
73+
cancel-in-progress: false # don't cancel in-progress runs as we want to allow these production deployments to complete
74+
75+
environment:
76+
name: github-pages
77+
url: ${{ steps.deployment.outputs.page_url }}
78+
79+
steps:
80+
6181
- name: Deploy to GitHub Pages
62-
if: github.ref == 'refs/heads/master'
63-
# TODO: consider switching to JamesIves/github-pages-deploy-action
64-
# uses: JamesIves/[email protected]
65-
# with:
66-
# branch: gh-pages
67-
# folder: _book
68-
uses: crazy-max/[email protected]
69-
with:
70-
target_branch: gh-pages
71-
build_dir: _book
72-
jekyll: false
73-
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
id: deployment
83+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)