This repository has been archived by the owner on Jun 5, 2024. It is now read-only.
generated from fastai/fastpages
-
Notifications
You must be signed in to change notification settings - Fork 416
139 lines (124 loc) · 4.73 KB
/
update-nb.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
132
133
134
135
136
137
138
139
name: Update Notebooks And Refresh Page
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
update-notebooks:
runs-on: ubuntu-latest
steps:
- name: See event name
run: |
echo "title ${title}"
echo "actor ${actor}"
echo "event_name ${event_name}"
env:
title: ${{ github.event.issue.title }}
actor: ${{ github.actor }}
event_name: ${{ github.event_name }}
- name: Copy Repository Contents
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: install dependencies
run: |
pip3 install -r ./_notebooks/requirements.txt
python3 -m ipykernel install --user --name python3
sudo chmod -R 777 .
- name: update notebooks
id: update_nb
run: |
./_action_files/run_notebooks.sh
- name: Create an issue if notebook update failure occurs
if: github.event_name == 'schedule' && steps.update_nb.outputs.error_bool == 'true'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var err = process.env.ERROR_STRING;
var run_id = process.env.RUN_ID;
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Error updating notebooks",
body: `These are the notebooks that failed to update properly: \n${err}\n\n See run [${run_id}](https://github.com/github/covid19-dashboard/actions/runs/${run_id}) for more details.`
})
env:
ERROR_STRING: ${{ steps.update_nb.outputs.error_str }}
RUN_ID: ${{ github.run_id }}
- name: convert notebooks and word docs to posts
uses: ./_action_files
- name: setup directories for Jekyll build
run: |
rm -rf _site
sudo chmod -R 777 .
- name: Jekyll build
uses: docker://hamelsmu/fastpages-jekyll
with:
args: bash -c "gem install bundler && jekyll build -V"
env:
JEKYLL_ENV: 'production'
- name: copy CNAME file into _site if CNAME exists
run: |
sudo chmod -R 777 _site/
cp CNAME _site/ 2>/dev/null || :
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.SSH_DEPLOY_KEY }}
publish_dir: ./_site
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
force_orphan: true
- name: Comment on issue if failure in updating notebooks
if: github.event_name == 'issues' && steps.update_nb.outputs.error_bool == 'true'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var run_id = process.env.RUN_ID;
var err = process.env.ERROR_STRING;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `An error occurred when attempting to refresh one or more of the notebooks in run [${run_id}](https://github.com/github/covid19-dashboard/actions/runs/${run_id}). These are the notebooks that failed to update properly: \n${err}`
})
env:
ERROR_STRING: ${{ steps.update_nb.outputs.error_str }}
RUN_ID: ${{ github.run_id }}
- name: Comment on issue if failure in workflow
if: failure() && github.event_name == 'issues'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var run_id = process.env.RUN_ID;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `An workflow error occurred in run [${run_id}](https://github.com/github/covid19-dashboard/actions/runs/${run_id}) when attempting to refresh the notebooks.`
})
env:
RUN_ID: ${{ github.run_id }}
- name: Comment on and close issue if successful
if: github.event_name == 'issues' && steps.update_nb.outputs.error_bool == 'false'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'All notebooks updated successfully.'
})
github.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})