-
Notifications
You must be signed in to change notification settings - Fork 1
99 lines (82 loc) · 3.29 KB
/
deploy_book-template.yml
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
89
90
91
92
93
94
95
96
97
98
99
on:
push:
branches:
- main
paths:
- book-template/**
- .github/workflows/deploy_book-template.yml
name: render-book-template
jobs:
render-book-template:
name: Render and upload the book template for the workshops
runs-on: ubuntu-latest
defaults:
run:
working-directory: book-template
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Cache R packages
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: r-${{ hashFiles('DESCRIPTION') }}
- name: Install pandoc and pandoc citeproc
uses: r-lib/actions/setup-pandoc@v2
- name: Install R packages and dependencies
run: |
Rscript -e 'options(Ncpus = 4); pkgs = c("rmarkdown", "bookdown", "formatR", "palmerpenguins");
if(length(new.pkgs <- setdiff(pkgs, rownames(installed.packages())))) install.packages(new.pkgs)'
- name: Render the book using bookdown
run: Rscript -e 'bookdown::render_book("index.Rmd")'
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: book-template
path: book-template/
# Need to first create an empty gh-pages branch
# see https://pkgdown.r-lib.org/reference/deploy_site_github.html
# and also add secrets for a GH_PAT and EMAIL to the repository
# gh-action from Cecilapp/GitHub-Pages-deploy
checkout-and-deploy-book-template:
name: Checkout and deploy the book within the gh-pages repository
runs-on: ubuntu-latest
needs: render-book-template
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Download Artifact
uses: actions/download-artifact@v3
with:
# Artifact name
name: book-template # optional
# Destination path
path: book-template/ # optional
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.ACCESS_TOKEN }}
branch: gh-pages # The branch the action should deploy to.
folder: book-template/_book/
target-folder: book-template # The folder the action should deploy
clean: true
# Dispatch a ping to the workshops repositories that will be received by a workflow, which in turn, will trigger the other workflows
# Transform into a matrix to add all workshops
dispatch-to-workshops:
name: Dispatch changes to workshop repositories
runs-on: ubuntu-latest
needs: checkout-and-deploy-book-template
strategy:
matrix:
workshop: [workshop01, workshop02, workshop03, workshop04, workshop05, workshop06, workshop07, workshop08, workshop09, workshop10]
steps:
- name: PING BOOK - Dispatch initiating repository event to the workshop receiving workflow
run: |
curl -X POST https://api.github.com/repos/QCBSRworkshops/${{ matrix.workshop }}/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.ACCESS_TOKEN }} \
--data '{"event_type": "ping_book", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'