From 69f7eb34f315648fb2a23da3c741323711fd1cc8 Mon Sep 17 00:00:00 2001 From: Pritma Gaikwad Date: Sun, 23 Jun 2024 18:04:47 +0530 Subject: [PATCH 1/2] gitthub action added for context-v2 label --- .github/workflows/label.yml | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/label.yml diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 00000000..355e420a --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,71 @@ +name: Auto Label New Issues, PRs, and Discussions + +on: + issues: + types: [opened] + pull_request: + types: [opened] + discussion: + types: [created] + +jobs: + add-label: + runs-on: ubuntu-latest + + permissions: + issues: write + discussions: write + pull-requests: write + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO_OWNER: ${{ github.repository_owner }} + REPO_NAME: ${{ github.event.repository.name }} + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Add context-v2 label to new issue + id: label-issue + if: github.event_name == 'issues' + run: | + ISSUE_NUMBER=${{ github.event.issue.number }} + gh issue edit "$ISSUE_NUMBER" --add-label "context-v2" + + - name: Add context-v2 label to new PR + id: label-pr + if: github.event_name == 'pull_request' + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + gh pr edit "$PR_NUMBER" --add-label "context-v2" + + - name: Get label id for discussion + id: label-data + if: github.event_name == 'discussion' + run: | + res="$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/$REPO_OWNER/$REPO_NAME/labels/context-v2 --jq '.node_id')" + echo "label_id=$res" >> $GITHUB_OUTPUT + + - name: Add context-v2 label to new discussion + uses: octokit/graphql-action@v2.x + id: lable-discussion + if: github.event_name == 'discussion' + env: + DISCUSSION_ID: ${{ github.event.discussion.node_id }} + LABEL_ID: ${{ steps.label-data.outputs.label_id }} + with: + query: | + mutation { + addLabelsToLabelable( + input:{ + labelableId: "${{env.DISCUSSION_ID}}" + labelIds: ["${{ env.LABEL_ID}}"] + } + ) { + clientMutationId + } + } From 431d16811acfae01b8078f52c147388855187648 Mon Sep 17 00:00:00 2001 From: Pritma Gaikwad Date: Mon, 24 Jun 2024 10:38:37 +0530 Subject: [PATCH 2/2] context-v2 label changes github action --- .github/workflows/label.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml index 355e420a..eaeef183 100644 --- a/.github/workflows/label.yml +++ b/.github/workflows/label.yml @@ -3,7 +3,7 @@ name: Auto Label New Issues, PRs, and Discussions on: issues: types: [opened] - pull_request: + pull_request_target: types: [opened] discussion: types: [created] @@ -21,21 +21,19 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO_OWNER: ${{ github.repository_owner }} REPO_NAME: ${{ github.event.repository.name }} - + steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Add context-v2 label to new issue - id: label-issue if: github.event_name == 'issues' run: | ISSUE_NUMBER=${{ github.event.issue.number }} gh issue edit "$ISSUE_NUMBER" --add-label "context-v2" - name: Add context-v2 label to new PR - id: label-pr - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request_target' run: | PR_NUMBER=${{ github.event.pull_request.number }} gh pr edit "$PR_NUMBER" --add-label "context-v2" @@ -52,9 +50,8 @@ jobs: - name: Add context-v2 label to new discussion uses: octokit/graphql-action@v2.x - id: lable-discussion if: github.event_name == 'discussion' - env: + env: DISCUSSION_ID: ${{ github.event.discussion.node_id }} LABEL_ID: ${{ steps.label-data.outputs.label_id }} with: