generated from carpentries-incubator/template
-
-
Notifications
You must be signed in to change notification settings - Fork 15
131 lines (116 loc) · 3.7 KB
/
pr-receive.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
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
name: "Receive Pull Request"
on:
pull_request:
types:
[opened, synchronize, reopened]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test-pr:
name: "Record PR number"
if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
outputs:
is_valid: ${{ steps.check-pr.outputs.VALID }}
steps:
- name: "Record PR number"
id: record
if: ${{ always() }}
run: |
echo ${{ github.event.number }} > ${{ github.workspace }}/NR # 2022-03-02: artifact name fixed to be NR
- name: "Upload PR number"
id: upload
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: pr
path: ${{ github.workspace }}/NR
- name: "Get Invalid Hashes File"
id: hash
run: |
echo "json<<EOF
$(curl -sL https://files.carpentries.org/invalid-hashes.json)
EOF" >> $GITHUB_OUTPUT
- name: "echo output"
run: |
echo "${{ steps.hash.outputs.json }}"
- name: "Check PR"
id: check-pr
uses: carpentries/actions/check-valid-pr@main
with:
pr: ${{ github.event.number }}
invalid: ${{ fromJSON(steps.hash.outputs.json)[github.repository] }}
build-md-source:
name: "Build markdown source files if valid"
needs: test-pr
runs-on: ubuntu-latest
if: ${{ needs.test-pr.outputs.is_valid == 'true' }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv/
CHIVE: ${{ github.workspace }}/site/chive
PR: ${{ github.workspace }}/site/pr
MD: ${{ github.workspace }}/site/built
steps:
- name: "Check Out Main Branch"
uses: actions/checkout@v3
- name: "Check Out Staging Branch"
uses: actions/checkout@v3
with:
ref: md-outputs
path: ${{ env.MD }}
- name: "Set up R"
uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
install-r: false
- name: "Set up Pandoc"
uses: r-lib/actions/setup-pandoc@v2
- name: "Setup Lesson Engine"
uses: carpentries/actions/setup-sandpaper@main
with:
cache-version: ${{ secrets.CACHE_VERSION }}
- name: "Setup Package Cache"
uses: carpentries/actions/setup-lesson-deps@main
with:
cache-version: ${{ secrets.CACHE_VERSION }}
- name: "Validate and Build Markdown"
id: build-site
run: |
sandpaper::package_cache_trigger(TRUE)
sandpaper::validate_lesson(path = '${{ github.workspace }}')
sandpaper:::build_markdown(path = '${{ github.workspace }}', quiet = FALSE)
shell: Rscript {0}
- name: "Generate Artifacts"
id: generate-artifacts
run: |
sandpaper:::ci_bundle_pr_artifacts(
repo = '${{ github.repository }}',
pr_number = '${{ github.event.number }}',
path_md = '${{ env.MD }}',
path_pr = '${{ env.PR }}',
path_archive = '${{ env.CHIVE }}',
branch = 'md-outputs'
)
shell: Rscript {0}
- name: "Upload PR"
uses: actions/upload-artifact@v3
with:
name: pr
path: ${{ env.PR }}
- name: "Upload Diff"
uses: actions/upload-artifact@v3
with:
name: diff
path: ${{ env.CHIVE }}
retention-days: 1
- name: "Upload Build"
uses: actions/upload-artifact@v3
with:
name: built
path: ${{ env.MD }}
retention-days: 1
- name: "Teardown"
run: sandpaper::reset_site()
shell: Rscript {0}