From f52b5ff7ef7759bf7e1ee6c0fcaf006f580addf9 Mon Sep 17 00:00:00 2001 From: cansavvy Date: Fri, 7 Jun 2024 16:51:00 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20Created=20local=20'.github/switc?= =?UTF-8?q?h=5Fsync=5Frepo.R'=20from=20remote=20'.github/switch=5Fsync=5Fr?= =?UTF-8?q?epo.R'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit release- --- .github/switch_sync_repo.R | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/switch_sync_repo.R diff --git a/.github/switch_sync_repo.R b/.github/switch_sync_repo.R new file mode 100644 index 0000000..7975abf --- /dev/null +++ b/.github/switch_sync_repo.R @@ -0,0 +1,39 @@ +#!/usr/bin/env Rscript + +# This script switches the repo entry for the yaml file to whatever is specified +# Written by Candace Savonen Jan 2022 + +if (!("optparse" %in% installed.packages())){ + install.packages("optparse") +} + +library(optparse) + +option_list <- list( + optparse::make_option( + c("--repo"), + type = "character", + default = "jhudsl/OTTR_Template_Test", + help = "GitHub repository name, e.g. jhudsl/OTTR_Template_Test", + ) +) + +# Read the arguments passed +opt_parser <- optparse::OptionParser(option_list = option_list) +opt <- optparse::parse_args(opt_parser) + +# Find .git root directory +root_dir <- rprojroot::find_root(rprojroot::has_dir(".git")) + +# Get test sync yaml path +sync_file_path <- file.path(root_dir, ".github", "test-sync.yml") + +yaml_contents <- yaml::yaml.load_file(sync_file_path) + +# Only keep first grouping +yaml_contents$group <- yaml_contents$group[[1]] + +# Switch out repo +yaml_contents$group$repos <- opt$repo + +yaml::write_yaml(yaml_contents, sync_file_path)