Skip to content

Update publications #35

Update publications

Update publications #35

Workflow file for this run

name: Update publications
on:
schedule:
# 05:00 UTC on first day of every month
# (min, hr, day (month), month, day (week)
- cron: "0 5 1 * *"
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
poetry-version: ['1.2.2']
steps:
- name: Checkout master branch
uses: actions/checkout@master
- name: Select Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Setup Poetry ${{ matrix.poetry-version }}
uses: Gr1N/setup-poetry@v8
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Check cache
uses: actions/cache@v3
id: cache
with:
path: ~/.cache/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install requirements
if: steps.cache.outputs.cache-hit != true
run: |
poetry install --with actions
- name: Run notebook
run: |
poetry run ipython kernel install --name "khanlab.github.io" --user
poetry run papermill ${{ github.workspace }}/get_publications.ipynb ${{ github.workspace }}/get_publications.ipynb
- name: New article condition
id: article-condition
run: |
if grep -q "0 new articles found." ${{ github.workspace }}/get_publications.ipynb; then
echo '::set-output name=hit::false'
else
echo '::set-output name=hit::true'
fi
# Creates a PR for review if new article(s) found
- name: Create pull request
uses: peter-evans/create-pull-request@v4
if: steps.article-condition.outputs.hit == 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Update publications by Actions bot
title: '[MAINT] Update publications spreadsheet'
body: 'New publications found - please check before merging: https://github.com/khanlab/khanlab.github.io/blob/update_publications/get_publications.ipynb'
base: master
branch: update_publications
# Directly commits to master if no new articles found
- name: Commit publications file
id: commit-pub
if: steps.article-condition.outputs.hit != 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Update publications spreadsheet" -a
- name: Push to master
uses: ad-m/github-push-action@master
if: steps.article-condition.outputs.hit != 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}