.github/workflows/GetCiteNum.yml #608
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
# This is a basic workflow to help you get started with Actions | |
# Controls when the workflow will run | |
on: | |
schedule: | |
# * 00:00 UTC+8 everyday | |
- cron: '0 16 * * *' | |
permissions: | |
contents: write | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "get" | |
get: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
# Runs a single command using the runners shell | |
- name: Run a python script | |
run: python3 GetCiteNum.py | |
- name: Check for changes | |
id: git-check | |
run: | | |
if [[ -z "$(git status --porcelain)" ]]; then | |
echo "changed=\"false\"" >> $GITHUB_OUTPUT | |
else | |
echo "changed=\"true\"" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit and push changes | |
run: | | |
if [[ "${{ steps.git-check.outputs.changed }}" == "true" ]]; then | |
git config --global user.name 'CiteNumBot' | |
git config --global user.email 'actions@github.com' | |
git add README.md | |
git commit -m "Update number of references" | |
git push | |
else | |
echo "No changes to commit." | |
fi |