This repository has been archived by the owner on Jun 5, 2024. It is now read-only.
Update Notebooks And Refresh Page #5094
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
}) |