From e9906fbe50aadca3d388de0c930dddabd9fec2ac Mon Sep 17 00:00:00 2001 From: Sachin Prasad Date: Mon, 22 Jan 2024 14:37:18 -0800 Subject: [PATCH 1/5] Create auto-assignment.yaml --- .github/workflows/auto-assignment.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/auto-assignment.yaml diff --git a/.github/workflows/auto-assignment.yaml b/.github/workflows/auto-assignment.yaml new file mode 100644 index 0000000000..de72da8ba2 --- /dev/null +++ b/.github/workflows/auto-assignment.yaml @@ -0,0 +1,21 @@ +name: auto-assignment +on: + issues: + types: + - opened + +permissions: + contents: read + issues: write + pull-requests: write + +jobs: + welcome: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/github-script@v7 + with: + script: | + const script = require('./\.github/workflows/scripts/auto-assignment.js') + script({github, context}) From df964b4634592c331d78d913fb879a2256936664 Mon Sep 17 00:00:00 2001 From: Sachin Prasad Date: Mon, 22 Jan 2024 14:41:40 -0800 Subject: [PATCH 2/5] Create auto-assignment.js --- .github/workflows/scripts/auto-assignment.js | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/scripts/auto-assignment.js diff --git a/.github/workflows/scripts/auto-assignment.js b/.github/workflows/scripts/auto-assignment.js new file mode 100644 index 0000000000..d08b06a8b7 --- /dev/null +++ b/.github/workflows/scripts/auto-assignment.js @@ -0,0 +1,43 @@ +/** Automatically assign issues and PRs to users in the `assigneesList` + * on a rotating basis. + + @param {!object} + GitHub objects can call GitHub APIs using their built-in library functions. + The context object contains issue and PR details. +*/ + +module.exports = async ({ github, context }) => { + let issueNumber; + let assigneesList; + // Is this an issue? If so, assign the issue number. Otherwise, assign the PR number. + if (context.payload.issue) { + //assignee List for issues. + assigneesList = ["SuryanarayanaY", "sachinprasadhs"]; + issueNumber = context.payload.issue.number; + } else { + //assignee List for PRs. + assigneesList = []; + issueNumber = context.payload.number; + } + console.log("assignee list", assigneesList); + console.log("entered auto assignment for this issue: ", issueNumber); + if (!assigneesList.length) { + console.log("No assignees found for this repo."); + return; + } + let noOfAssignees = assigneesList.length; + let selection = issueNumber % noOfAssignees; + let assigneeForIssue = assigneesList[selection]; + + console.log( + "issue Number = ", + issueNumber + " , assigning to: ", + assigneeForIssue + ); + return github.rest.issues.addAssignees({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + assignees: [assigneeForIssue], + }); +}; From 2b3f2aa199a26148f9c666c026cffb38afc52d20 Mon Sep 17 00:00:00 2001 From: Sachin Prasad Date: Mon, 22 Jan 2024 14:46:19 -0800 Subject: [PATCH 3/5] Create stale-issue-pr.yaml --- .github/workflows/stale-issue-pr.yaml | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/stale-issue-pr.yaml diff --git a/.github/workflows/stale-issue-pr.yaml b/.github/workflows/stale-issue-pr.yaml new file mode 100644 index 0000000000..034fb4c266 --- /dev/null +++ b/.github/workflows/stale-issue-pr.yaml @@ -0,0 +1,50 @@ +name: Close inactive issues +on: + schedule: + - cron: "30 1 * * *" +jobs: + close-issues: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - name: Awaiting response issues + uses: actions/stale@v9 + with: + days-before-issue-stale: 14 + days-before-issue-close: 14 + stale-issue-label: "stale" + # reason for closed the issue default value is not_planned + close-issue-reason: completed + only-labels: "stat:awaiting response from contributor" + stale-issue-message: > + This issue is stale because it has been open for 14 days with no activity. + It will be closed if no further activity occurs. Thank you. + # List of labels to remove when issues/PRs unstale. + labels-to-remove-when-unstale: "stat:awaiting response from contributor" + close-issue-message: > + This issue was closed because it has been inactive for 28 days. + Please reopen if you'd like to work on this further. + days-before-pr-stale: 14 + days-before-pr-close: 14 + stale-pr-message: "This PR is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you." + close-pr-message: "This PR was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further." + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Contribution issues + uses: actions/stale@v9 + with: + days-before-issue-stale: 180 + days-before-issue-close: 365 + stale-issue-label: "stale" + # reason for closed the issue default value is not_planned + close-issue-reason: not_planned + any-of-labels: "stat:contributions welcome,good first issue" + # List of labels to remove when issues/PRs unstale. + labels-to-remove-when-unstale: "stat:contributions welcome,good first issue" + stale-issue-message: > + This issue is stale because it has been open for 180 days with no activity. + It will be closed if no further activity occurs. Thank you. + close-issue-message: > + This issue was closed because it has been inactive for more than 1 year. + repo-token: ${{ secrets.GITHUB_TOKEN }} From f63d070b4a1658398172d2cfbbd6d1a6a8b86c5f Mon Sep 17 00:00:00 2001 From: Sachin Prasad Date: Mon, 22 Jan 2024 14:46:54 -0800 Subject: [PATCH 4/5] Rename auto-assignment.yaml to auto-assignment.yml --- .github/workflows/{auto-assignment.yaml => auto-assignment.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{auto-assignment.yaml => auto-assignment.yml} (100%) diff --git a/.github/workflows/auto-assignment.yaml b/.github/workflows/auto-assignment.yml similarity index 100% rename from .github/workflows/auto-assignment.yaml rename to .github/workflows/auto-assignment.yml From a890a18424978bb8a8c9dfdfbc2126484cafdb34 Mon Sep 17 00:00:00 2001 From: Sachin Prasad Date: Mon, 22 Jan 2024 14:47:11 -0800 Subject: [PATCH 5/5] Rename stale-issue-pr.yaml to stale-issue-pr.yml --- .github/workflows/{stale-issue-pr.yaml => stale-issue-pr.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{stale-issue-pr.yaml => stale-issue-pr.yml} (100%) diff --git a/.github/workflows/stale-issue-pr.yaml b/.github/workflows/stale-issue-pr.yml similarity index 100% rename from .github/workflows/stale-issue-pr.yaml rename to .github/workflows/stale-issue-pr.yml