From 5a9c5762b5bbfb4eb743e9881be482840f6a07b7 Mon Sep 17 00:00:00 2001 From: Bikrant Jajware <34072248+bikrantjajware@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:25:56 +0000 Subject: [PATCH 1/3] added github actions to check assigned issues to issue's author --- .github/workflows/check-issue-author.yml | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/check-issue-author.yml diff --git a/.github/workflows/check-issue-author.yml b/.github/workflows/check-issue-author.yml new file mode 100644 index 00000000000..11fc18b95a8 --- /dev/null +++ b/.github/workflows/check-issue-author.yml @@ -0,0 +1,39 @@ +name: "check issues author" + +on: + issues: + types: [opened, edited] + +jobs: + check-issue-author: + permissions: + issues: write + runs-on: ubuntu-latest + steps: + - name: check if issue author has assigned issues + id: check-assignee + run: | + ISSUE_AUTHOR=${{ github.event.issue.user.login }} + ISSUES=$(curl \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -s "https://api.github.com/search/issues?q=repo:${{ github.repository }}+is:open+is:issue+assignee:$ISSUE_AUTHOR" | jq .total_count) + echo "issue author $ISSUE_AUTHOR" + echo "has_issues=$(test $ISSUES -gt 0 && echo true || echo false)" >> $GITHUB_OUTPUT + + - name: Update issue if author has issues + if: steps.check-assignee.outputs.has_issues == 'true' + run: | + ISSUE_AUTHOR=${{ github.event.issue.user.login }} + ISSUE_URL="https://github.com/$GITHUB_REPOSITORY/issues/${{ github.event.issue.number }}" + ASSIGNED_ISSUE_URL="https://github.com/$GITHUB_REPOSITORY/issues?q=is%3Aopen+is%3Aissue+assignee%3A$ISSUE_AUTHOR" + MESSAGE="${{ github.event.issue.body }}\n\nℹ️ **$ISSUE_AUTHOR** has some opened assigned issues: 🔧[View assigned issues]($ASSIGNED_ISSUE_URL)" + echo "Updating issue with message: $MESSAGE" + curl -L \ + -X PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + ISSUE_URL \ + -d "{\"body\":\"$MESSAGE\"}" \ No newline at end of file From 6662eef74c97a154a7dec5848746a604c2e9efb5 Mon Sep 17 00:00:00 2001 From: Bikrant Jajware Date: Fri, 27 Oct 2023 21:47:23 +0530 Subject: [PATCH 2/3] feat: add check-issue-author workflow --- .github/workflows/check-author-issues.yml | 47 +++++++++++++++++++++++ .github/workflows/check-issue-author.yml | 39 ------------------- 2 files changed, 47 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/check-author-issues.yml delete mode 100644 .github/workflows/check-issue-author.yml diff --git a/.github/workflows/check-author-issues.yml b/.github/workflows/check-author-issues.yml new file mode 100644 index 00000000000..a6e282fba25 --- /dev/null +++ b/.github/workflows/check-author-issues.yml @@ -0,0 +1,47 @@ +name: "check author issues" + +on: + issues: + types: [opened, edited] + +jobs: + check-issue-author: + permissions: + issues: write + runs-on: ubuntu-latest + steps: + - name: check author issue assignment choice + run: | + CHOICE=$(echo "${{ github.event.issue.body }}" | grep -A 3 "Do you want to work on this issue?\(\s*\)" | ( grep -oiE "yes" || echo "No" )) + echo "CHOICE=$CHOICE" >> $GITHUB_ENV + + - name: check if issue author has assigned issues + if: env.CHOICE == 'Yes' + id: check-assignee + run: | + ISSUE_AUTHOR=${{ github.event.issue.user.login }} + ISSUES=$(curl \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -s "https://api.github.com/search/issues?q=repo:${{ github.repository }}+is:open+is:issue+assignee:$ISSUE_AUTHOR" | jq .total_count) + echo "issue author $ISSUE_AUTHOR" + echo "has_issues=$(test $ISSUES -gt 0 && echo true || echo false)" >> $GITHUB_OUTPUT + + - name: Update issue if author has assigned issues + if: steps.check-assignee.outputs.has_issues == 'true' + run: | + ISSUE_AUTHOR=${{ github.event.issue.user.login }} + ISSUE_NUMBER=${{ github.event.issue.number }} + ISSUE_URL="https://github.com/$GITHUB_REPOSITORY/issues/$ISSUE_NUMBER" + ASSIGNED_ISSUES_URL="https://github.com/$GITHUB_REPOSITORY/issues?q=is%3Aopen+is%3Aissue+assignee%3A$ISSUE_AUTHOR" + UPDATE_TEXT="ℹ️ **$ISSUE_AUTHOR** has some opened assigned issues: 🔧[View assigned issues]($ASSIGNED_ISSUES_URL)" + OLD_BODY="${{ github.event.issue.body }}" + BODY=$(jq --arg old_body "$OLD_BODY" --arg update_text "$UPDATE_TEXT" -n '{ body: ($old_body + "\n\n" + $update_text) }') + curl -L \ + -X PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$ISSUE_NUMBER \ + -s -d "$BODY" \ No newline at end of file diff --git a/.github/workflows/check-issue-author.yml b/.github/workflows/check-issue-author.yml deleted file mode 100644 index 11fc18b95a8..00000000000 --- a/.github/workflows/check-issue-author.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: "check issues author" - -on: - issues: - types: [opened, edited] - -jobs: - check-issue-author: - permissions: - issues: write - runs-on: ubuntu-latest - steps: - - name: check if issue author has assigned issues - id: check-assignee - run: | - ISSUE_AUTHOR=${{ github.event.issue.user.login }} - ISSUES=$(curl \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -s "https://api.github.com/search/issues?q=repo:${{ github.repository }}+is:open+is:issue+assignee:$ISSUE_AUTHOR" | jq .total_count) - echo "issue author $ISSUE_AUTHOR" - echo "has_issues=$(test $ISSUES -gt 0 && echo true || echo false)" >> $GITHUB_OUTPUT - - - name: Update issue if author has issues - if: steps.check-assignee.outputs.has_issues == 'true' - run: | - ISSUE_AUTHOR=${{ github.event.issue.user.login }} - ISSUE_URL="https://github.com/$GITHUB_REPOSITORY/issues/${{ github.event.issue.number }}" - ASSIGNED_ISSUE_URL="https://github.com/$GITHUB_REPOSITORY/issues?q=is%3Aopen+is%3Aissue+assignee%3A$ISSUE_AUTHOR" - MESSAGE="${{ github.event.issue.body }}\n\nℹ️ **$ISSUE_AUTHOR** has some opened assigned issues: 🔧[View assigned issues]($ASSIGNED_ISSUE_URL)" - echo "Updating issue with message: $MESSAGE" - curl -L \ - -X PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - ISSUE_URL \ - -d "{\"body\":\"$MESSAGE\"}" \ No newline at end of file From b9090cfc5c651babbf54d294de97b30b6cbbab1c Mon Sep 17 00:00:00 2001 From: Eddie Jaoude Date: Sat, 28 Oct 2023 09:20:09 +0100 Subject: [PATCH 3/3] Update .github/workflows/check-author-issues.yml --- .github/workflows/check-author-issues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-author-issues.yml b/.github/workflows/check-author-issues.yml index a6e282fba25..487a6688a70 100644 --- a/.github/workflows/check-author-issues.yml +++ b/.github/workflows/check-author-issues.yml @@ -44,4 +44,4 @@ jobs: -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$GITHUB_REPOSITORY/issues/$ISSUE_NUMBER \ - -s -d "$BODY" \ No newline at end of file + -s -d "$BODY"