From 0692c51f0d43a82d3ec0d6efe1a11f9c4b829980 Mon Sep 17 00:00:00 2001 From: Sebastian Villena <97059974+ruisebas@users.noreply.github.com> Date: Fri, 16 Aug 2024 16:17:25 -0400 Subject: [PATCH] chore: Adding actions to update labels --- .github/workflows/issue_closed.yml | 8 ++++---- .github/workflows/issue_comment.yml | 26 ++++++++++++++++++-------- .github/workflows/issue_opened.yml | 22 +++++++++++++++++++++- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.github/workflows/issue_closed.yml b/.github/workflows/issue_closed.yml index 822ba28..53b2529 100644 --- a/.github/workflows/issue_closed.yml +++ b/.github/workflows/issue_closed.yml @@ -10,16 +10,16 @@ permissions: jobs: cleanup-labels: runs-on: ubuntu-latest - if: ${{ (contains(github.event.issue.labels.*.name, 'pending-response') || contains(github.event.issue.labels.*.name, 'closing soon') || contains(github.event.issue.labels.*.name, 'pending-release')) }} + if: ${{ contains(github.event.issue.labels.*.name, 'pending-community-response') || contains(github.event.issue.labels.*.name, 'pending-maintainer-response') || contains(github.event.issue.labels.*.name, 'closing soon') || contains(github.event.issue.labels.*.name, 'pending-release') || contains(github.event.issue.labels.*.name, 'pending-triage') }} steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 - - name: remove unnecessary labels after closing + - name: Remove unnecessary labels after closing shell: bash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY_NAME: ${{ github.event.repository.full_name }} run: | - gh issue edit $ISSUE_NUMBER --remove-label "closing soon" --remove-label "pending-response" --remove-label "pending-release" + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "closing soon" --remove-label "pending-community-response" --remove-label "pending-maintainer-response" --remove-label "pending-release" --remove-label "pending-triage" comment-visibility-warning: runs-on: ubuntu-latest diff --git a/.github/workflows/issue_comment.yml b/.github/workflows/issue_comment.yml index 55c66ea..ba18f18 100644 --- a/.github/workflows/issue_comment.yml +++ b/.github/workflows/issue_comment.yml @@ -19,17 +19,27 @@ jobs: shell: bash run: echo $COMMENT | sed "s/\\\n/. /g; s/\\\r//g; s/[^a-zA-Z0-9 &().,:]//g" | xargs -I {} curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data '{"comment":"{}", "commentUrl":"'$COMMENT_URL'", "user":"'$USER'"}' - remove-pending-response-label: + adjust-labels: runs-on: ubuntu-latest permissions: issues: write - if: ${{ !github.event.issue.pull_request && contains(github.event.issue.labels.*.name, 'pending-response') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY_NAME: ${{ github.event.repository.full_name }} steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 - - name: remove unnecessary labels after closing + - name: remove pending-community-response when new comment received + if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) && !github.event.issue.pull_request }} + shell: bash + run: | + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-community-response" + - name: add pending-maintainer-response when new community comment received + if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }} + shell: bash + run: | + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-maintainer-response" + - name: remove pending-maintainer-response when new owner/member comment received + if: ${{ contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }} shell: bash - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ISSUE_NUMBER: ${{ github.event.issue.number }} run: | - gh issue edit $ISSUE_NUMBER --remove-label "pending-response" \ No newline at end of file + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-maintainer-response" \ No newline at end of file diff --git a/.github/workflows/issue_opened.yml b/.github/workflows/issue_opened.yml index 36654c7..9fca7c3 100644 --- a/.github/workflows/issue_opened.yml +++ b/.github/workflows/issue_opened.yml @@ -18,6 +18,25 @@ jobs: shell: bash run: echo $ISSUE | sed 's/[^a-zA-Z0-9 &().,:]//g' | xargs -I {} curl -s POST "$WEBHOOK_URL" -H "Content-Type:application/json" --data '{"issue":"{}", "issueUrl":"'$ISSUE_URL'", "user":"'$USER'"}' + add-issue-opened-labels: + runs-on: ubuntu-latest + permissions: + issues: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY_NAME: ${{ github.event.repository.full_name }} + steps: + - name: Add the pending-triage label + shell: bash + run: | + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-triage" + - name: Add the pending-maintainer-response label + if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }} + shell: bash + run: | + gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-maintainer-response" + maintainer-opened: runs-on: ubuntu-latest permissions: @@ -29,5 +48,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ISSUE_NUMBER: ${{ github.event.issue.number }} + REPOSITORY_NAME: ${{ github.event.repository.full_name }} run: | - gh issue comment $ISSUE_NUMBER --repo aws-amplify/amplify-ios-maplibre -b "This issue was opened by a maintainer of this repository; updates will be posted here. If you are also experiencing this issue, please comment here with any relevant information so that we're aware and can prioritize accordingly." + gh issue comment $ISSUE_NUMBER --repo $REPOSITORY_NAME -b "This issue was opened by a maintainer of this repository; updates will be posted here. If you are also experiencing this issue, please comment here with any relevant information so that we're aware and can prioritize accordingly."