From f19e4192ffa2a62bd43c5697559ee8c4a393fede Mon Sep 17 00:00:00 2001 From: Ben Francom <5726729+bfrancom@users.noreply.github.com> Date: Sat, 23 Mar 2024 16:27:12 -0600 Subject: [PATCH] Add option to run github action on linux runner and fix token issue --- .github/workflows/linux.yml | 59 +++++++++++++++++++++++++++++++++++++ .github/workflows/run.yml | 2 ++ README.md | 2 +- 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/linux.yml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..e3c2162 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,59 @@ +name: Get Lines of Code for GitHub Organizations +on: + workflow_dispatch: + inputs: + test_org_name: + description: 'Name of the TEST environment GitHub Organization(s)' + required: true + default: '' + prod_org_name: + description: 'Name of the PROD environment GitHub Organization(s)' + required: true + default: '' +env: + GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }} +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: 3.0 + + - name: Install Dependencies and Cleanup + run: sudo apt-get install -y cloc + + - name: Calculating LoC for each org + run: | + IFS=',' read -ra ORGS <<< "${{ github.event.inputs.test_org_name }}" + for org in "${ORGS[@]}"; do + bundle exec ruby loc.rb "$org" + done + prod: + timeout-minutes: 60 + needs: test + #May need to add a "Pay as you go", larger GitHub-hosted runner depending on the size of each repo + #See https://docs.github.com/en/actions/using-github-hosted-runners/about-larger-runners/about-larger-runners + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: 3.0 + + - name: Install Dependencies and Cleanup + run: sudo apt-get install -y cloc + + - name: Calculating LoC for each org + run: | + IFS=',' read -ra ORGS <<< "${{ github.event.inputs.prod_org_name }}" + for org in "${ORGS[@]}"; do + bundle exec ruby loc.rb "$org" + done diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 31a3a61..61ff23c 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -7,6 +7,8 @@ on: description: 'The org (or user) to calculate total lines of code' required: false type: string +env: + GITHUB_TOKEN: ${{ secrets.ORG_GITHUB_TOKEN }} jobs: run: runs-on: macos-latest diff --git a/README.md b/README.md index 1bb8365..c6c35e6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Don't want to set up a local development environment? You can run this script vi You'll see the progress and count(s) in the job output (also available from the Actions tab). -Note: If you'd like to count private repositories, as described below, you'll need to set a `GITHUB_TOKEN` GitHub Actions secret. +Note: If you'd like to count private repositories, as described below, you'll need to set an `ORG_GITHUB_TOKEN` GitHub Actions secret with your PAT. ## How it works