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