From aea9fd08caa4c67c35095560ce1bf81dd6e87e68 Mon Sep 17 00:00:00 2001 From: "Timothy J. Aveni" Date: Thu, 7 Sep 2023 18:33:17 -0700 Subject: [PATCH] Dockerize GitHub repos script --- scripts/github-repos/Dockerfile | 12 ++++++++++++ scripts/github-repos/README.md | 26 ++++++++++++++++++++++++++ scripts/github-repos/github-repos.rb | 4 +--- 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 scripts/github-repos/Dockerfile diff --git a/scripts/github-repos/Dockerfile b/scripts/github-repos/Dockerfile new file mode 100644 index 0000000..6a700ee --- /dev/null +++ b/scripts/github-repos/Dockerfile @@ -0,0 +1,12 @@ +FROM ruby:3.2.2-bookworm + +WORKDIR /app + +COPY ["Gemfile", "/app/Gemfile"] +COPY ["Gemfile.lock", "/app/Gemfile.lock"] + +run bundle install + +COPY ["github-repos.rb", "/app/github-repos.rb"] + +ENTRYPOINT ["ruby", "github-repos.rb"] diff --git a/scripts/github-repos/README.md b/scripts/github-repos/README.md index 3210ded..88a00e1 100644 --- a/scripts/github-repos/README.md +++ b/scripts/github-repos/README.md @@ -54,3 +54,29 @@ Remove all students and subteams in STUDENTTEAM from the org. **Use case:** Only remove the access of students teams, repos still can be accessed by gsi team. +## Running with Docker + +Instead of switching to the right Ruby version manually, you can also build and use a Docker image to run this script. + +### To build + +To create the Docker image, clone this repository, cd into the script directory, and run: + +``` +docker build -t saasbook-script-github-repos . +``` + +### To run + +Run the following, replacing the appropriate parameters. + +If using Windows, you may need to change the `\`pwd\`` mount. Files in the working directory will be available to the container at `/app/files`, e.g. `-c /app/files/team-info.csv`. + +``` +docker run \ + -v `pwd`:/app/files \ + -e GITHUB_ORG_API_KEY=[ghp_your_key] \ + saasbook-script-github-repos \ + [args] \ + [command] +``` diff --git a/scripts/github-repos/github-repos.rb b/scripts/github-repos/github-repos.rb index 7f258df..8bf32ea 100755 --- a/scripts/github-repos/github-repos.rb +++ b/scripts/github-repos/github-repos.rb @@ -4,8 +4,6 @@ require 'octokit' require 'csv' -ENV['GITHUB_ORG_API_KEY'] = "" - def main() puts "Script start." org = OrgManager.new @@ -223,4 +221,4 @@ def remove_access end end -main \ No newline at end of file +main