-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from fhdsl/cansavvy/write-csv
Saving github data to our ITN thing
- Loading branch information
Showing
15 changed files
with
270 additions
and
77 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ | |
resources/* | ||
^doc$ | ||
^Meta$ | ||
inst/extdata/docker/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Candace Savonen Jan 2024 | ||
|
||
name: Build Docker | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
dockerhubpush: | ||
description: 'Push to Dockerhub?' | ||
required: true | ||
default: 'false' | ||
tag: | ||
description: 'What tag to use?' | ||
required: true | ||
default: 'none' | ||
jobs: | ||
build-docker: | ||
name: Build Docker image | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login as jhudsl-robot | ||
run: | | ||
git config --system --add safe.directory "$GITHUB_WORKSPACE" | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "jhudsl-robot" | ||
# Set up Docker build | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
# Setup layer cache | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
# Set up Docker build | ||
- name: Set up Docker Build | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Get token | ||
run: echo ${{ secrets.GH_PAT }} > ${{ inputs.directory }}/git_token.txt | ||
|
||
# Build docker image | ||
- name: Build Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: false | ||
load: true | ||
context: docker | ||
file: inst/extdata/Dockerfile | ||
tags: hutch/gimap | ||
|
||
# Login to Dockerhub | ||
- name: Login to DockerHub | ||
if: ${{ github.event.inputs.dockerhubpush != 'false' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Push the Docker image if set to true from a manual trigger | ||
- name: Push Docker image if manual trigger set to true | ||
if: ${{ github.event.inputs.dockerhubpush != 'false' }} | ||
run: | | ||
docker tag jhudsl/base_ottr:latest jhudsl/base_ottr:$github.event.inputs.tag | ||
docker push jhudsl/base_ottr:$github.event.inputs.tag |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ local_auth.R | |
local_auth_2.R | ||
/doc/ | ||
/Meta/ | ||
git_token.txt |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM rocker/tidyverse:4.0.2 | ||
LABEL maintainer="[email protected]" | ||
WORKDIR /rocker-build/ | ||
|
||
COPY install_github.R . | ||
COPY git_token.txt . | ||
COPY github_package_list.tsv . | ||
|
||
|
||
# Install packages from github | ||
RUN Rscript install_github.R \ | ||
--packages github_package_list.tsv \ | ||
--token git_token.txt | ||
|
||
|
||
# Set final workdir for commands | ||
WORKDIR /home/rstudio |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fhdsl/metricminer HEAD |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env Rscript | ||
|
||
if (!"optparse" %in% installed.packages()) { | ||
install.packages("optparse") | ||
} | ||
|
||
library(optparse) | ||
|
||
################################ Set up options ################################ | ||
# Set up optparse options | ||
option_list <- list( | ||
make_option( | ||
opt_str = c("-p", "--packages"), type = "character", | ||
default = "github_package_list.tsv" , | ||
help = "Path to a TSV with a list of packages to be installed through Github, | ||
where file where the first column is the github package name e.g. | ||
jhudsl/ottrpal and the second column is the commit ID to be installed | ||
(to be supplied to the ref argument). | ||
", | ||
metavar = "character" | ||
), | ||
make_option( | ||
opt_str = c("--token"), type = "character", | ||
default = NULL, | ||
help = "GITHUB PAT file", | ||
metavar = "character" | ||
) | ||
) | ||
|
||
# Parse options | ||
opt <- parse_args(OptionParser(option_list = option_list)) | ||
|
||
# Read in the token | ||
token <- as.character(readLines(opt$token)[1]) | ||
|
||
# Reset GITHUB PAT to be token | ||
Sys.unsetenv("GITHUB_PAT") | ||
Sys.setenv(GITHUB_PAT = token) | ||
|
||
# set up list of packages to install | ||
packages <- readr::read_tsv(opt$packages, | ||
col_names = c("package_name", "ref")) | ||
|
||
purrr::pmap( | ||
packages, | ||
~remotes::install_github(..1, | ||
auth_token = token, | ||
ref = ..2) | ||
) | ||
|
||
# Remove the file after we are done | ||
file.remove(opt$token) |
Oops, something went wrong.