Skip to content

Commit

Permalink
Introduce Paper Add/Update workflows (#460)
Browse files Browse the repository at this point in the history
Co-authored-by:  dvdkouril <[email protected]>
  • Loading branch information
manzt and dvdkouril authored Oct 8, 2024
1 parent ebc0fba commit f81d51f
Show file tree
Hide file tree
Showing 8 changed files with 1,052 additions and 127 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: true
88 changes: 88 additions & 0 deletions .github/ISSUE_TEMPLATE/paper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: "📚 Add or Update a Paper"
description: "Add or update a paper from Zotero to the HIDIVE website"
labels: ["paper-bot"]
body:
- type: markdown
attributes:
value: |
This template is for adding or updating a paper on the HIDIVE website.
Upon submission, a **GitHub Action** will start a **pull request** to update the website with the new paper details.
- type: input
id: zotero_id
attributes:
label: Zotero ID
description: >-
Enter the Zotero ID from either the HIDIVE Lab [preprint collection](https://www.zotero.org/groups/5145258/hidive/collections/AJKTPNSI)
or [publication collection](https://www.zotero.org/groups/5145258/hidive/collections/YGTEVG73).
This ID will be used to automatically fetch all publication details from Zotero.
placeholder: "e.g., D8YCD6QT"
validations:
required: true

- type: input
id: preprint
attributes:
label: Preprint
description: >-
Enter a Zotero ID or URL for the preprint. **Leave blank if the Zotero ID above is for a preprint**.
placeholder: "e.g., A6ZAJIIA or https://arxiv.org/abs/1234.56789"

- type: markdown
attributes:
value: |
> [!NOTE]
> Prefer a preprint Zotero ID above if **updating a preprint to a publication**. It will update the existing website entry.
### Optional Fields
The following fields are optional. They can be left blank and updated later if needed.
- type: textarea
id: members
attributes:
label: Lab Members
description: "Tag lab members on paper. See the [lab member](https://github.com/hms-dbmi/gehlenborglab-website/tree/main/_members) directory for available identifiers, one per line."
placeholder: "nils-gehlenborg\nflat-stanley\njane-doe"

- type: textarea
id: image
attributes:
label: Image
description: "Add an image related to the publication"
placeholder: "Drage and drop or paste an image... (ensure it uploads)"

- type: input
id: website
attributes:
label: Website
description: "A URL for a website related to the publication"
placeholder: "e.g., https://example.com/publication-website"

- type: input
id: code
attributes:
label: Code Repository
description: "A link for the code related to the publication"
placeholder: "e.g., https://github.com/username/repo"

- type: textarea
id: videos
attributes:
label: Video Resources
description: "List video resources related to the publication. Use the format 'Title | URL' for each entry, one per line."
placeholder: "Introduction Video | https://example.com/intro\nConference Presentation | https://example.com/presentation"

- type: textarea
id: other_resources
attributes:
label: Other Resources
description: "List other resources related to the publication. Use the format 'Title | URL' for each entry, one per line."
placeholder: "Data Repository | https://example.com/data\nSlides | https://example.com/slides"

- type: textarea
id: awards
attributes:
label: Awards
description: "Enter awards for the publication (one per line)"
placeholder: "Best Paper Award at XXX\nInnovation Prize Y\nMost Cited Paper 2054"
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request]

jobs:
build:

if: github.repository == 'hms-dbmi/gehlenborglab-website'
# Available versions:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -57,4 +57,4 @@ jobs:
- name: Invalidate Cache
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |
aws cloudfront create-invalidation --distribution-id ${{secrets.CF_DISTRIBUTION_ID}} --paths "/*"
aws cloudfront create-invalidation --distribution-id ${{secrets.CF_DISTRIBUTION_ID}} --paths "/*"
48 changes: 48 additions & 0 deletions .github/workflows/fetch-papers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Fetch HIDIVE Papers

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # Every Monday at 00:00

permissions:
contents: write
issues: write
pull-requests: write

jobs:
fetch-papers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Fetch HIDIVE Papers
run: deno run -A scripts/fetch-hidive-zotero-items.ts --outdir=assets/papers --issue-file=/tmp/issue-body.md

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit-message: Fetch HIDIVE Papers
title: "Update HIDIVE Papers"
branch: hidive-papers
body: "This is an automated pull request to update the HIDIVE papers."
labels: fetch-papers-bot

- name: Open or Update Missing Papers Issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Check if an issue with the label 'fetch-papers-bot' exists
ISSUE_NUMBER=$(gh issue list --label fetch-papers-bot --limit 1 --json number --jq '.[0].number')
if [ -n "$ISSUE_NUMBER" ]; then
# Update existing issue
gh issue edit $ISSUE_NUMBER --body-file /tmp/issue-body.md
echo "Updated existing issue #$ISSUE_NUMBER"
else
gh issue create --title "Missing HIDIVE Papers" --body-file /tmp/issue-body.md --label fetch-papers-bot
echo "Created new issue for missing papers"
fi
53 changes: 53 additions & 0 deletions .github/workflows/update-paper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Update Paper

on:
issues:
types: [opened, edited]

permissions:
contents: write
issues: write
pull-requests: write

jobs:
process-issue:
if: contains(github.event.issue.labels.*.name, 'paper-bot')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Parse Issue
id: parse-issue
uses: GrantBirki/[email protected]
with:
body: ${{ github.event.issue.body }}
csv_to_list: false

- name: Create PR body with Fixes line
run: |
echo "Fixes #${{ github.event.issue.number }}" > /tmp/pr-body.md
echo "" >> /tmp/pr-body.md
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Update Paper
id: output-issue
run: echo ${{ toJson(steps.parse-issue.outputs.json) }} | deno run -A scripts/update-hidive-paper.ts - >> /tmp/pr-body.md

- name: Extract Zotero ID
id: extract-zotero-id
run: |
ZOTERO_ID=$(echo ${{ toJson(steps.parse-issue.outputs.json) }} | jq -r .zotero_id)
echo "zotero-id=$ZOTERO_ID" >> $GITHUB_OUTPUT
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit-message: Update paper
title: "${{ github.event.issue.title }}"
branch: "update-paper-${{ steps.extract-zotero-id.outputs.zotero-id }}"
body-path: /tmp/pr-body.md
labels: paper-bot
Loading

0 comments on commit f81d51f

Please sign in to comment.