From bbbc838e13238e2b8c8fbf12e7ceb7f1a8c4adf1 Mon Sep 17 00:00:00 2001 From: Gowroji Sunil <48122892+sgowroji@users.noreply.github.com> Date: Thu, 2 Mar 2023 01:25:15 +0530 Subject: [PATCH] Adds not stale label on copybara-service[bot] PR's (#4517) Adds not stale label on copybara-service[bot] PR's. This workflow will not allow stale bot to act on copybara PR's --- .github/workflows/notstale.yml | 43 ++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/notstale.yml diff --git a/.github/workflows/notstale.yml b/.github/workflows/notstale.yml new file mode 100644 index 00000000000..e4612e18d11 --- /dev/null +++ b/.github/workflows/notstale.yml @@ -0,0 +1,43 @@ +# This workflow adds not stale label to only copybara[bot] PRs to avoid stale workflow +# +# You can adjust the behavior by modifying this file. +# For more information, see: +# https://github.com/actions-ecosystem/action-add-labels +name: Label Not Stale PRs + +on: + pull_request: + types: [opened, synchronize] + +jobs: + label-not-stale-prs: + runs-on: ubuntu-latest + steps: + - name: Check PR author + id: pr-author-check + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const author = context.payload.pull_request.user.login; + return { author: author }; + + - name: Add "not stale" label + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + async function run() { + const author = context.payload.pull_request.user.login; + if (author === "copybara-service[bot]") { + const issue_number = context.payload.pull_request.number; + const labels = ["not stale"]; + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + labels: labels + }); + } + } + run();