diff --git a/.github/workflows/auto_comment_on_issue.yml b/.github/workflows/auto_comment_on_issue.yml new file mode 100644 index 0000000..817498a --- /dev/null +++ b/.github/workflows/auto_comment_on_issue.yml @@ -0,0 +1,36 @@ +name: Auto Comment on Issue + +on: + issues: + types: [opened] + +permissions: + issues: write + +jobs: + comment: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Add Comment to Issue + run: | + COMMENT=$(cat < { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue.number, + labels: [label] + }); + }; \ No newline at end of file diff --git a/.github/workflows/close_issue_on_pr_merge.yml b/.github/workflows/close_issue_on_pr_merge.yml new file mode 100644 index 0000000..3f681e3 --- /dev/null +++ b/.github/workflows/close_issue_on_pr_merge.yml @@ -0,0 +1,30 @@ +name: Close Issues on PR Merge + +on: + pull_request: + types: [closed] + +jobs: + close-issues: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Close linked issues + if: github.event.pull_request.merged == true + run: | + ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#') + for ISSUE in $ISSUES + do + echo "Closing issue #$ISSUE" + curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \ + -d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}' + curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \ + -d '{"state":"closed"}' + done \ No newline at end of file diff --git a/.github/workflows/comment_iss-close.yml b/.github/workflows/comment_iss-close.yml new file mode 100644 index 0000000..7c943e0 --- /dev/null +++ b/.github/workflows/comment_iss-close.yml @@ -0,0 +1,29 @@ +name: Comment on Issue Close + +on: + issues: + types: [closed] + +jobs: + greet-on-close: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Greet User + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue = context.payload.issue; + const issueCreator = issue.user.login; + const issueNumber = issue.number; + + const greetingMessage = `Hello @${issueCreator}! Your issue #${issueNumber} has been closed. Thank you for your contribution!`; + + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + body: greetingMessage + }); \ No newline at end of file