Export BugSigDB #15220
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
on: | |
schedule: | |
- cron: "55 * * * *" # UTC Time | |
workflow_dispatch: | |
name: Export BugSigDB | |
jobs: | |
export-bugsigdb: | |
runs-on: ubuntu-latest | |
container: bioconductor/bioconductor_docker:RELEASE_3_19 | |
steps: | |
- name: Checkout BugSigDBExports | |
uses: actions/checkout@v3 | |
with: | |
path: BugSigDBExports | |
- name: Install BugSigDBExports dependencies | |
run: | | |
Rscript -e "install.packages(c('rvest', 'readr', 'plyr', 'BiocFileCache', 'R.utils'))" | |
- name: Install bugsigdbr | |
run: | | |
Rscript -e "BiocManager::install('bugsigdbr')" | |
- name: Setup git config | |
run: | | |
cd $GITHUB_WORKSPACE/BugSigDBExports # Because we need to be in a repository | |
git config user.name "GitHub Actions Bot" | |
git config user.email "[email protected]" | |
- name: Export BugSigDB | |
run: | | |
BUGSIGDB_TIMESTAMP="$(date -u +%Y-%m-%d_%H:%M_UTC)" | |
echo "BUGSIGDB_TIMESTAMP=$BUGSIGDB_TIMESTAMP" >> $GITHUB_ENV | |
echo $BUGSIGDB_TIMESTAMP | |
Rscript $GITHUB_WORKSPACE/BugSigDBExports/inst/scripts/dump_release.R $BUGSIGDB_TIMESTAMP $GITHUB_WORKSPACE/BugSigDBExports | |
mv *csv $GITHUB_WORKSPACE/BugSigDBExports | |
timeout-minutes: 10 | |
- name: Track file growth | |
run: | | |
library(R.utils) | |
github_workspace <- Sys.getenv("GITHUB_WORKSPACE") | |
setwd(file.path(github_workspace, "BugSigDBExports")) | |
bugsigdb_timestamp <- Sys.getenv("BUGSIGDB_TIMESTAMP") | |
number_of_lines <- c("timestamp" = bugsigdb_timestamp) | |
files <- sort(list.files(pattern=".(csv|gmt)")) | |
files <- files[files != "file_size.csv"] | |
for (a_file in files) { | |
number_of_lines[a_file] <- countLines(a_file)[1] | |
} | |
write.table(as.matrix(t(number_of_lines)), | |
"file_size.csv", | |
append = TRUE, | |
col.names = FALSE, | |
row.names = FALSE) | |
shell: Rscript {0} | |
- name: Commit Exports | |
run: | | |
cd $GITHUB_WORKSPACE/BugSigDBExports | |
for export in `find . -type f -iname \*.gmt -o -iname \*.csv` | |
do | |
export=$(echo $export | sed 's/\.\///g') | |
git_diff=$(git diff --numstat $export | sed -e 's/\t//g') | |
if [ "$git_diff" = "11$export" -o "$git_diff" = "" ]; then | |
echo "No changes to commit for $export" | |
else | |
echo "Add changes for $export" | |
git add $export | |
fi | |
done | |
echo "Check if any file contents have added to the index" | |
has_updates=$(git diff --cached --shortstat) | |
if [ -n "$has_updates" ]; then | |
git add file_size.csv | |
git commit -m "Hourly export update" | |
git push origin devel | |
else | |
echo "No content changes to commit" | |
fi |