-
Notifications
You must be signed in to change notification settings - Fork 3
216 lines (184 loc) · 7.6 KB
/
build.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: build
on:
pull_request:
branches:
- main
workflow_dispatch:
push:
branches:
- 'main'
- 'test-build'
- 'docker-build'
tags:
- "v*"
env:
PARTICIPANT_DATA:
REGISTRY: ghcr.io
ORG: nbisweden
IMAGE: workshop-pgip/workshop-pgip:latest
jobs:
build:
runs-on: ubuntu-latest
name: Build site
timeout-minutes: 60
permissions:
contents: write
defaults:
run:
shell: bash -l {0}
steps:
- name: Set time zone
uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Stockholm"
timezoneMacos: "Europe/Stockholm"
timezoneWindows: "W. Europe Standard Time"
- name: Cancel Previous Runs
if: ${{ !env.ACT }}
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout repository
uses: actions/checkout@v4
- name: Pull image
run: docker pull ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}
- name: Define variables
run: |
echo "REPO=$(basename ${GITHUB_REPOSITORY})" >> $GITHUB_ENV
cd docs
echo "PATH_REPO=$(pwd)" >> $GITHUB_ENV
echo "PATH_EXPORT=$(grep -E 'output-dir' _quarto.yml | xargs | sed 's/output-dir://' | xargs)" >> $GITHUB_ENV
- name: Check docker and variables
run: |
docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v ${PWD}:/qmd ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }} Rscript -e "print('R in docker works!')"
echo "GITHUB_ACTOR: ${GITHUB_ACTOR}"
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}"
echo "REPO: ${REPO}"
echo "env.PATH_REPO: ${{ env.PATH_REPO }}"
echo "PATH_EXPORT: ${PATH_EXPORT}"
echo "PATH_EXPORT_CANVAS: ${PATH_EXPORT_CANVAS}"
echo "GITHUB_REPOSITORY_OWNER: ${GITHUB_REPOSITORY_OWNER}"
echo "---------------------------------------------------------------------------------------------"
echo "Folder contents at $(pwd):"
ls -lh
echo "---------------------------------------------------------------------------------------------"
printenv
sed --version
- name: Render site
run: |
# Add git info
git config --global user.email "[email protected]"
git config --global user.name "gh_action"
# Render website
echo "Rendering qmd files ..."
echo "pwd: ${pwd}"
echo "PWD: ${PWD}"
docker run --rm -u $(id -u ${USER}):$(id -g ${USER}) -v ${pwd}/scripts:/scripts -v ${pwd}/src:/src -v ${pwd}/docs:/qmd --env TEXINPUTS="../src/latex:$TEXINPUTS" ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}
# - name: Install pgip dependencies
# run: |
# python -m ipykernel install --user --name pgip --display-name "Population Genomics in Practice (Python)"
# python -m pip install git+https://github.com/NBISweden/pgip-tools
# python -m pip install git+https://github.com/ksamuk/pixy.git
# - name: Install dotenv
# run: |
# R -e "install.packages('dotenv', repos=c(CRAN = 'https://cran.rstudio.com/'))"
# - name: Install TeXLive
# run: |
# sudo apt-get update
# sudo apt-get install texlive texlive-latex-extra
# - name: Install local pgip R package
# run: |
# R -e "library(devtools); devtools::install_local('src/R/pgip', upgrade=F)"
# - name: Setup Quarto
# uses: quarto-dev/quarto-actions/setup@v2
# with:
# version: 1.3.450
# - run: |
# quarto --version
# - name: Add miniconda path
# run: |
# echo "$(dirname $(which R))" >> $GITHUB_PATH
# quarto check
# - name: "Set environment variables"
# run: |
# echo "TEXINPUTS=$TEXINPUTS:$GITHUB_WORKSPACE/src/latex" >> $GITHUB_ENV
# - name: Install dvisvgm
# run: |
# sudo apt-get install dvisvgm
# - name: Render project without publishing
# uses: quarto-dev/quarto-actions/render@v2
# if: ${{ github.event_name == 'pull_request' }}
# with:
# path: docs
# - name: Publish to GitHub Pages
# uses: quarto-dev/quarto-actions/publish@v2
# if: ${{ github.ref_name == 'main' || github.ref_name == 'test-build' }}
# with:
# target: gh-pages
# path: docs
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Create archive branch
# if: startsWith(github.ref, 'refs/tags/v')
# run: |
# echo "Creating archive branch archive-${{ github.ref_name }}"
# if git show-ref --quiet "refs/heads/archive-${{ github.ref_name }}"; then
# echo "archive-${{ github.ref_name }}" branch exists
# else
# echo "Running git branch archive-${{ github.ref_name }}"
# git branch "archive-${{ github.ref_name }}"
# fi
# - name: Render tag and save rendered state in separate branch
# if: startsWith(github.ref, 'refs/tags/v')
# env:
# GITHUB_EMAIL: [email protected]
# GITHUB_USERNAME: gh_action
# TARGET: "archive-${{ github.ref_name }}"
# run: |
# # Add git info
# git config --global user.email "${{ env.GITHUB_EMAIL }}"
# git config --global user.name "${{ env.GITHUB_USERNAME }}"
# git clone --single-branch --branch ${{ env.TARGET }} "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" tmprepo
# # - name: Render tag and save rendered state in separate branch
# # uses: quarto-dev/quarto-actions/publish@v2
# # if: startsWith(github.ref, 'refs/tags/v')
# # with:
# # target: "archive-${{ github.ref_name }}"
# # path: docs
# # env:
# # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Checkout archived course versions
# env:
# GITHUB_EMAIL: [email protected]
# GITHUB_USERNAME: gh_action
# TARGET: gh-pages
# run: |
# # Add git info
# git config --global user.email "${{ env.GITHUB_EMAIL }}"
# git config --global user.name "${{ env.GITHUB_USERNAME }}"
# git clone --single-branch --branch ${{ env.TARGET }} "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" tmprepo
# cd tmprepo
# mkdir -p archive
# cd archive
# git branch -l
# ls -lh
# # Add archive index page
# cat .header.html > index.html
# # Loop tags that match v\d+
# for tag in $(git tag --list v[0-9][0-9][0-9][0-9]); do
# if [ -d $tag ]; then
# echo "Directory ${tag} already exsists. Removing"
# git rm -f $tag
# fi
# git clone --depth 1 --branch "archive-$tag" "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" $tag
# git add -f $tag
# contents=$(git tag -n 100 $tag --format "%(contents)")
# echo "<section id=\"$tag\" class=\"level3\">" >> index.html
# echo "<h3 class=\"anchored\" data-anchor-id=\"$tag\">" >> index.html
# echo "<a href=\"$link\">$tag</a>" >> index.html
# echo "</h3>" >> index.html
# echo "<p>$contents</p>" >> index.html
# echo "</section>" >> index.html
# done
# cat .footer.html >> index.html
# git add -f index.html