From 232f4e1fddc745890be5981fd96fb7126ef259a2 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 12 Jan 2020 17:41:47 +0000 Subject: [PATCH] [Actions] Revert addition of auto-labeller action for `bottle :unneeded` (#48929) - I forgot that GitHub doesn't support secrets in Actions from forked repos, [until there was a legitimate use case for adding a label](https://github.com/Homebrew/homebrew-core/pull/48927), so the action will fail: ``` /opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/gems/octokit-4.15.0/lib/octokit/response/raise_error.rb:16:in `on_complete': POST https://api.github.com/repos/Homebrew/homebrew-core/issues/48927/labels: 403 - Resource not accessible by integration // See: https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue (Octokit::Forbidden) ``` - Given our PR workflow is "forked repo for everything", we can't do this until GitHub supports using secrets in forked PRs. It's a [requested feature](https://github.community/t5/GitHub-Actions/how-to-use-GITHUB-TOKEN-for-PRs-from-forks/td-p/37450). - Maybe at some other point in the future, we can revisit this and other auto-labelling actions. - I enjoyed making it nonetheless, and now I have "forked repos" to add to my testing for future Actions proof-of-concepts! ---- Reverts #48911 and supersedes #48919. --- .github/workflows/labels.yml | 19 ----------------- .github/workflows/scripts/add-labels.rb | 27 ------------------------- 2 files changed, 46 deletions(-) delete mode 100644 .github/workflows/labels.yml delete mode 100644 .github/workflows/scripts/add-labels.rb diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml deleted file mode 100644 index 09756cae57..0000000000 --- a/.github/workflows/labels.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Label PRs according to criteria - -on: - pull_request: - paths: - - 'Formula/*.rb' - -jobs: - label: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.6.3' - - run: gem install octokit - - run: ruby .github/workflows/scripts/add-labels.rb - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/scripts/add-labels.rb b/.github/workflows/scripts/add-labels.rb deleted file mode 100644 index 720d6b8ef9..0000000000 --- a/.github/workflows/scripts/add-labels.rb +++ /dev/null @@ -1,27 +0,0 @@ -require "octokit" - -client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"]) - -repo = ENV["GITHUB_REPOSITORY"] -pr_number = ENV["GITHUB_REF"].split("/")[2] - -pr_files = client.pull_request_files(repo, pr_number) - -pr_labels = { - no_bottles: 0 -} - -pr_files.each do |file| - formula = file[:filename] - - if File.exist?(formula) && File.read(formula).match(/bottle :unneeded/) - pr_labels[:no_bottles] += 1 - end -end - -if pr_files.count == pr_labels[:no_bottles] - puts "Adding the 'no-bottles' label." - client.add_labels_to_an_issue(repo, pr_number, ["no-bottles"]) -else - puts "Not labelling this PR as there's a mixture of bottled and unbottled formulae." -end