Skip to content

Commit

Permalink
ci to update all literature monthly
Browse files Browse the repository at this point in the history
  • Loading branch information
hdashnow committed Dec 30, 2024
1 parent 61a08d9 commit b65663c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
31 changes: 27 additions & 4 deletions .github/workflows/update-loci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Update data

permissions:
contents: write
pull-requests: write

on:
pull_request:
Expand All @@ -11,6 +12,8 @@ on:
- "scripts/**"
- "workflow/**"
- ".github/workflows/**"
schedule:
- cron: "45 2 1 * *" # Run monthly at 2:45 am
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -41,18 +44,38 @@ jobs:
conda info
- name: Check loci and update bed files (short)
#if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'}}
if: ${{ github.event_name == 'pull_request'}}
run: snakemake --config stages="skip-refs"

# Enable this step to open an SSH session for debugging
# - name: SSH debug
# uses: mxschmitt/action-tmate@v3

- name: Find new literature (intermediate)
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
conda init
source /home/runner/.bashrc
conda activate strchive
snakemake --config stages="new-refs"
- name: Update all literature (long)
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
run: |
conda init
source /home/runner/.bashrc
conda activate strchive
snakemake
- name: Open pull request with updated files
if: ${{ !(github.event_name == 'pull_request') }}
if: ${{ !(github.event_name == 'pull_request') || github.event_name == 'schedule' }}
uses: peter-evans/create-pull-request@v7
with:
branch: update-data
title: Update data

- name: Commit updated files to current pull request
if: ${{ github.event_name == 'pull_request' }}
if: ${{ github.event_name == 'pull_request' || github.event_name == 'schedule' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update data
commit_message: Update data
2 changes: 2 additions & 0 deletions scripts/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ dependencies:
- jsbeautifier
- statsmodels
- plotly
- zlib
- r-essentials
- r-base
- r-jsonlite
- r-dplyr
- r-rentrez
Expand Down
26 changes: 21 additions & 5 deletions scripts/get-literature.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@
# More useful error messages
options(error=traceback)

## Set default CRAN mirror
local({r <- getOption("repos")
r["CRAN"] <- "https://cran.r-project.org"
options(repos=r)
})

# Install biomaRt if not already installed
if (!requireNamespace("biomaRt", quietly = TRUE)) {
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
tryCatch({
if (!requireNamespace("biomaRt", quietly = TRUE)) {
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager", ask = FALSE, update = FALSE)
}
BiocManager::install("biomaRt", ask = FALSE)
}
BiocManager::install("biomaRt")
}
}, error = function(e) {
cat("Error installing biomaRt package.\n", file=stderr())
quit(status = 1)
})

tryCatch({
suppressPackageStartupMessages({
library(jsonlite)
library(dplyr)
Expand All @@ -21,6 +33,10 @@ suppressPackageStartupMessages({
library(stringr)
library(purrr)
})
}, error = function(e) {
cat("Error loading required packages.\n", file=stderr())
quit(status = 1)
})

### Data Setup
args <- commandArgs(trailingOnly = TRUE)
Expand Down

0 comments on commit b65663c

Please sign in to comment.