From 1fc5660610a0e4861ee8bfce1163d7b5d9a1aa32 Mon Sep 17 00:00:00 2001 From: Harshil Gupta Date: Mon, 10 Jun 2024 19:51:09 +0530 Subject: [PATCH 1/2] PR labels --- .github/workflows/auto-label.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index ba8a5f89..3de3cbb4 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -1,22 +1,21 @@ -name: Auto-label on Any Issue +name: Add Label on: issues: types: [opened] + pull_request: + types: [opened] jobs: - auto-label: + add_label: runs-on: ubuntu-latest steps: - - name: Add labels to new issue - uses: actions/github-script@v4 + - uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const labelsToAdd = ["gssoc"]; - await github.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - labels: labelsToAdd - }); + github.issues.listForRepo({ owner: context.repo.owner, repo: context.repo.repo }) + .then(response => response.data.map(issue => ({ issue_number: issue.number }))) + .then(issues => Promise.all(issues.map(issue => github.issues.addLabels(context.repo.owner, context.repo.repo, issue.issue_number, ["YOUR_LABEL"])))) + .then(() => console.log("Labels added successfully!")) + .catch(error => console.error(error)); From 19c2563d253ee90a44336fa23b0af022707af0f3 Mon Sep 17 00:00:00 2001 From: Harshil Gupta Date: Mon, 10 Jun 2024 20:23:16 +0530 Subject: [PATCH 2/2] update labeling --- .github/workflows/auto-label.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/auto-label.yml b/.github/workflows/auto-label.yml index 3de3cbb4..e6657e98 100644 --- a/.github/workflows/auto-label.yml +++ b/.github/workflows/auto-label.yml @@ -16,6 +16,5 @@ jobs: script: | github.issues.listForRepo({ owner: context.repo.owner, repo: context.repo.repo }) .then(response => response.data.map(issue => ({ issue_number: issue.number }))) - .then(issues => Promise.all(issues.map(issue => github.issues.addLabels(context.repo.owner, context.repo.repo, issue.issue_number, ["YOUR_LABEL"])))) - .then(() => console.log("Labels added successfully!")) + .then(issues => Promise.all(issues.map(issue => github.issues.addLabels(context.repo.owner, context.repo.repo, issue.issue_number, ["gssoc"])))) .catch(error => console.error(error));