Skip to content

[Fetch] Please include this pathway figure #18

[Fetch] Please include this pathway figure

[Fetch] Please include this pathway figure #18

name: Fetch this figure
on:
issues:
types: [labeled]
jobs:
fetch-figure:
if: github.event.label.name == 'fetch'
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: false # to allow multiple runs to queue up rather than clobber
steps:
- uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
with:
r-version: '4.2.1'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev
Rscript -e 'install.packages(c("rentrez", "xml2", "httr", "yaml", "stringr"))'
- name: Extract PMCID and Figure Number
id: extract
run: |
# Print raw issue body for debugging
echo "Raw issue body:"
echo "${{ github.event.issue.body }}"
echo "---"
# Clean and normalize the issue body
cleaned_body=$(echo "${{ github.event.issue.body }}" | tr -d '\r' | tr '\n' ' ' | sed 's/[[:space:]]\+/ /g')
echo "Cleaned issue body:"
echo "$cleaned_body"
echo "---"
# Extract PMCID
pmcid=$(echo "$cleaned_body" | sed -n 's/.*### PMCID *\([^ ]*\).*/\1/p')
echo "Extracted PMCID: '$pmcid'"
# Extract Figure Number
figure_number=$(echo "$cleaned_body" | sed -n 's/.*### Figure Number *\([^ ]*\).*/\1/p')
echo "Extracted Figure Number: '$figure_number'"
# Set outputs
echo "pmcid=$pmcid" >> $GITHUB_OUTPUT
echo "figure_number=$figure_number" >> $GITHUB_OUTPUT
- name: Fetch Figure
run: |
Rscript scripts/fetch_THIS_figure_v2.R "${{ steps.extract.outputs.pmcid }}" "${{ steps.extract.outputs.figure_number }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
commit-message: Add figure ${{ steps.extract.outputs.pmcid }}_${{ steps.extract.outputs.figure_number }}
title: Add figure ${{ steps.extract.outputs.pmcid }}_${{ steps.extract.outputs.figure_number }}
body: |
This PR adds a new figure:
- PMCID: ${{ steps.extract.outputs.pmcid }}
- Figure Number: ${{ steps.extract.outputs.figure_number }}
branch: add-figure-${{ steps.extract.outputs.pmcid }}-${{ steps.extract.outputs.figure_number }}
delete-branch: true
labels: |
fetch
- name: Close Issue
uses: peter-evans/close-issue@v3
with:
issue-number: ${{ github.event.issue.number }}
comment: |
A new figure (ID: ${{ steps.fetch_figure.outputs.figid }}) has been fetched and a pull request has been created to add it to the repository.