Skip to content

Update Papers with Code #209

Update Papers with Code

Update Papers with Code #209

# Fetches metadata from Papers with Code and commits changes
name: Update Papers with Code
# Controls when the workflow will run.
# We run it once a week to minimize merge commits.
on:
# Triggers the workflow at 0:30 UTC every Thursday
schedule:
- cron: '30 0 * * 4'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
ingest-pwc:
runs-on: ubuntu-22.04
steps:
- name: Update system
run: sudo apt-get update
- name: Install dependencies
run: sudo apt-get install -y jing bibutils openssh-client rsync libyaml-dev libpython3-dev python3-lxml
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
name: Checkout master branch
with:
ref: master
fetch-depth: 0
- id: update-pwc-metadata
name: Update PwC metadata
run: |
python3 bin/ingest_pwc.py
git add data/xml/*xml
make check_staged_xml
# Check conditions for creating a PR
# - commits-this-week: number of commits (on master) by the bot during the last 6 days
# - lines-changed: number of added + deleted lines by the update-pwc-metadata step
- id: check-if-pr
name: Check if PR should be created
if: steps.update-pwc-metadata.conclusion == 'success'
run: |
echo "commits-this-week="$(git log --author='acl-pwc-bot' --after=$(date --date='6 days ago' +%Y-%m-%d) --oneline | wc -l) >> $GITHUB_OUTPUT
echo "lines-changed="$(git diff --cached --numstat data/xml/*xml | awk 'BEGIN {s=0} {s+=$1; s+=$2} END {print s}' -) >> $GITHUB_OUTPUT
- uses: peter-evans/create-pull-request@v3
id: create-pr
name: Create pull request
if: steps.check-if-pr.outputs.lines-changed > 0
with:
token: ${{ secrets.PWC_BOT_TOKEN }}
branch: automated/update-pwc-metadata
author: "acl-pwc-bot <acl-pwc-bot@bollmann.me>"
commit-message: "Update metadata from Papers with Code"
title: "[automated] Update metadata from Papers with Code"
body: |
**Auto-generated PR by GitHub action; will be merged automatically.**
Update ${{ steps.check-if-pr.outputs.lines-changed }} lines of XML data from [Papers with Code](https://paperswithcode.com/).
delete-branch: true
- uses: hmarr/auto-approve-action@v2
name: Automatically approve PR
if: steps.create-pr.outputs.pull-request-operation == 'created'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}