-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (78 loc) · 2.98 KB
/
Build pkgdown site.yaml
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
name: Build pkgdown site
on:
workflow_dispatch: # Trigger manually
workflow_run:
workflows: ["Trigger Build pkgdown Site"]
types:
- completed
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} # Use the event name, branch reference, and workflow name as the concurrency group
cancel-in-progress: true # Cancel any in-progress runs in the same group
jobs:
build-site:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}
env:
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GH_PAT }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Debug concurrency group
run: |
echo "Concurrency group:"
echo "${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libxml2-dev libssl-dev libcurl4-openssl-dev
sudo apt-get install -y libharfbuzz-dev libfribidi-dev
sudo apt-get install -y pandoc
sudo apt-get install -y libudunits2-dev
sudo apt-get install -y libgeos-dev libproj-dev libgdal-dev
- name: Install R package dependencies
run: |
install.packages('remotes')
remotes::install_deps(dependencies = TRUE)
install.packages('devtools')
devtools::install_github('inbo/fistools', auth_token = Sys.getenv("GITHUB_PAT"))
shell: Rscript {0}
- name: Install pkgdown
run: install.packages('pkgdown')
shell: Rscript {0}
- name: pull changes to branch if any
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git pull --rebase origin ${{ github.head_ref }}
- name: Build pkgdown site
run: pkgdown::build_site()
shell: Rscript {0}
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -A
if ! git diff --cached --quiet; then
git commit -m 'Build pkgdown site [skip ci]'
# Extract the branch name from the full reference
BRANCH_NAME=${GITHUB_REF##*/}
git pull --rebase origin "$BRANCH_NAME"
git push origin "$BRANCH_NAME" # Push to the correct branch
else
echo "No changes to commit."
fi