Zotero → Slack #22439
This file contains hidden or 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: Zotero → Slack | |
| on: | |
| schedule: | |
| - cron: '*/5 * * * *' | |
| workflow_dispatch: | |
| jobs: | |
| post-new-papers: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@v4 | |
| with: | |
| persist-credentials: true | |
| - name: Install Python + jq | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y jq | |
| python -m pip install --upgrade pip | |
| pip install requests python-dateutil | |
| - name: Run ZotBot | |
| id: run-zotbot | |
| env: | |
| ZOTERO_GROUP: ${{ secrets.ZOTERO_GROUP }} | |
| ZOTERO_COLLECTION: ${{ secrets.ZOTERO_COLLECTION }} | |
| ZOTERO_API_KEY: ${{ secrets.ZOTERO_API_KEY }} | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| run: | | |
| chmod +x zotbot.py | |
| python zotbot.py \ | |
| --group $ZOTERO_GROUP \ | |
| --collection $ZOTERO_COLLECTION \ | |
| --api $ZOTERO_API_KEY \ | |
| --webhook $SLACK_WEBHOOK_URL \ | |
| --artifact zotbot.json \ | |
| --channel "#papers" \ | |
| --username "ZotBot" \ | |
| --icon ":robot_face:" | |
| - name: Commit updated artifact | |
| if: steps.run-zotbot.conclusion == 'success' | |
| run: | | |
| # Set up git identity | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Pull & rebase upstream, stashing your JSON changes automatically | |
| git pull --rebase --autostash origin master | |
| # Stage the (force-add if in .gitignore) artifact | |
| git add -f zotbot.json | |
| # Only commit & push if there’s something new | |
| if git diff --cached --quiet; then | |
| echo "No artifact changes to commit" | |
| else | |
| git commit -m "[MNT] Update ZotBot artifact" | |
| git push origin master | |
| fi |