From 0229c7603d7112cf46c1603159bbb77e0bf360ea Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 17:23:42 +0200 Subject: [PATCH 1/9] first draft for github action --- .github/workflows/retraction-check.yml | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/retraction-check.yml diff --git a/.github/workflows/retraction-check.yml b/.github/workflows/retraction-check.yml new file mode 100644 index 0000000..db2f24e --- /dev/null +++ b/.github/workflows/retraction-check.yml @@ -0,0 +1,37 @@ +name: Retraction Check + +on: + workflow_dispatch: # Allows manual trigger + schedule: + - cron: '0 8 * * 1' # Runs every Monday at 08:00 UTC + +jobs: + retraction_check: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install . + + - name: Run retraction check + id: retraction + run: | + python -m retraction_check.check_bib sample.bib > findings.txt + grep -v "No retracted papers found." findings.txt > findings_only.txt || true + + - name: Create issue if retractions found + if: success() && hashFiles('findings_only.txt') != '' + uses: peter-evans/create-issue-from-file@v5 + with: + title: "Retraction Watch: Retracted Papers Detected in Bibliography" + content-filepath: findings_only.txt + labels: retraction, automated-check From ae8af328ef47afd0f81d1100052afc45e2ac194d Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 17:50:18 +0200 Subject: [PATCH 2/9] fix install --- .github/workflows/retraction-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/retraction-check.yml b/.github/workflows/retraction-check.yml index db2f24e..c45c26f 100644 --- a/.github/workflows/retraction-check.yml +++ b/.github/workflows/retraction-check.yml @@ -20,7 +20,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install . + pip install retraction_check - name: Run retraction check id: retraction From 13b1dd4a19f9d3837c2e58c0231e9b593d2839f8 Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 17:50:41 +0200 Subject: [PATCH 3/9] add testwise running for pr on this branch --- .github/workflows/retraction-check.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/retraction-check.yml b/.github/workflows/retraction-check.yml index c45c26f..d807a32 100644 --- a/.github/workflows/retraction-check.yml +++ b/.github/workflows/retraction-check.yml @@ -4,6 +4,9 @@ on: workflow_dispatch: # Allows manual trigger schedule: - cron: '0 8 * * 1' # Runs every Monday at 08:00 UTC + pull_request: + branches: + - feat/github-action jobs: retraction_check: From b9696d1373d2d2964e671cf8b5c090bc13623f7f Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 17:52:28 +0200 Subject: [PATCH 4/9] change to commit --- .github/workflows/retraction-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/retraction-check.yml b/.github/workflows/retraction-check.yml index d807a32..d38dfa4 100644 --- a/.github/workflows/retraction-check.yml +++ b/.github/workflows/retraction-check.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: # Allows manual trigger schedule: - cron: '0 8 * * 1' # Runs every Monday at 08:00 UTC - pull_request: + commit: branches: - feat/github-action From 60f6348fe4b61b11a9f24c2af535b630cb3a4800 Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 17:53:38 +0200 Subject: [PATCH 5/9] syntax fix --- .github/workflows/retraction-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/retraction-check.yml b/.github/workflows/retraction-check.yml index d38dfa4..5f7401a 100644 --- a/.github/workflows/retraction-check.yml +++ b/.github/workflows/retraction-check.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: # Allows manual trigger schedule: - cron: '0 8 * * 1' # Runs every Monday at 08:00 UTC - commit: + push: branches: - feat/github-action From b92e68815d31a71e55b69c4172f2ea4a071b744f Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 17:56:51 +0200 Subject: [PATCH 6/9] add writing permissions --- .github/workflows/retraction-check.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/retraction-check.yml b/.github/workflows/retraction-check.yml index 5f7401a..5d0b336 100644 --- a/.github/workflows/retraction-check.yml +++ b/.github/workflows/retraction-check.yml @@ -11,6 +11,8 @@ on: jobs: retraction_check: runs-on: ubuntu-latest + permissions: + issues: write steps: - name: Checkout repository uses: actions/checkout@v4 From 2207096d530cfad3a56e549e47e92ace45c952cd Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 18:04:57 +0200 Subject: [PATCH 7/9] add example to readme --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/README.md b/README.md index e1d710e..a8bf093 100644 --- a/README.md +++ b/README.md @@ -84,3 +84,56 @@ pipenv run check-all - Python 3.8+ - bibtexparser - requests + +## Example: Automated Retraction Check with GitHub Actions + +You can automate retraction checks for your bibliography file using GitHub Actions. The following workflow runs the check on demand, on a schedule, or on every commit to a specific branch. If any retractions are found, it will open a GitHub issue listing the findings. + +```yaml +name: Retraction Check + +on: + workflow_dispatch: # Allows manual trigger + schedule: + - cron: '0 8 * * 1' # Runs every Monday at 08:00 UTC + push: + paths: + - yourfile.bib # Change this to your personal bib file to make sure the workflow runs every time the bibfile changes + +jobs: + retraction_check: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install . + + - name: Run retraction check + id: retraction + run: | + python -m retraction_check.check_bib path/to/your/bibfileyourfile.bib > findings.txt + grep -v "No retracted papers found." findings.txt > findings_only.txt || true + + - name: Create issue if retractions found + if: success() && hashFiles('findings_only.txt') != '' + uses: peter-evans/create-issue-from-file@v5 + with: + title: "Retraction Watch: Retracted Papers Detected in Bibliography" + content-filepath: findings_only.txt + labels: retraction, automated-check +``` + +- Replace `yourfile.bib` with the path to your bibliography file. +- The workflow will create an issue only if retractions are found. +- You can trigger the workflow manually, on a schedule, or on every commit to the specified branch. From 7062b5475cd5cf7a3e99e4bee9caa98a3fc5b9dd Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 18:05:03 +0200 Subject: [PATCH 8/9] remove running on demo branch --- .github/workflows/retraction-check.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/retraction-check.yml b/.github/workflows/retraction-check.yml index 5d0b336..d734932 100644 --- a/.github/workflows/retraction-check.yml +++ b/.github/workflows/retraction-check.yml @@ -5,8 +5,8 @@ on: schedule: - cron: '0 8 * * 1' # Runs every Monday at 08:00 UTC push: - branches: - - feat/github-action + paths: + - sample.bib jobs: retraction_check: From 18d31076b29be093cde4211b7a26b2ab4d9b7f89 Mon Sep 17 00:00:00 2001 From: codingfabi Date: Thu, 4 Sep 2025 18:08:07 +0200 Subject: [PATCH 9/9] add gitlab example --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index a8bf093..f8ad9b0 100644 --- a/README.md +++ b/README.md @@ -137,3 +137,38 @@ jobs: - Replace `yourfile.bib` with the path to your bibliography file. - The workflow will create an issue only if retractions are found. - You can trigger the workflow manually, on a schedule, or on every commit to the specified branch. + +## Example: Automated Retraction Check with GitLab CI + +You can also automate retraction checks for your bibliography file using GitLab CI/CD. The following example runs the check on every push to the default branch and creates an issue if retractions are found (requires a GitLab personal access token with API scope stored as `GITLAB_TOKEN`). + +```yaml +retraction_check: + image: python:3.11 + stage: test + script: + - pip install . + - python -m retraction_check.check_bib path/to/yourfile.bib > findings.txt + - grep -v "No retracted papers found." findings.txt > findings_only.txt || true + # Only create an issue if findings_only.txt is not empty + - | + if [ -s findings_only.txt ]; then + curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \ + --header "Content-Type: application/json" \ + --data '{ + "title": "Retraction Watch: Retracted Papers Detected in Bibliography", + "description": "$(cat findings_only.txt)", + "labels": "retraction, automated-check" + }' \ + --request POST "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/issues" + fi + only: + - main # or your default branch + rules: + - changes: + - path/to/yourfile.bib +``` + +- Replace `path/to/yourfile.bib` with the path to your bibliography file. +- Store a GitLab personal access token with API scope as a CI/CD variable named `GITLAB_TOKEN`. +- The job will create an issue only if retractions are found and the `.bib` file changes.