From 9e5fca36ce43692081b7c1346596759b9549218b Mon Sep 17 00:00:00 2001 From: Anushka Chouhan Date: Tue, 5 Nov 2024 18:23:28 +0530 Subject: [PATCH] Update Workflow --- .github/workflows/auto-comment-issues.yml | 18 ++++++++++++ .github/workflows/auto-comment-prs.yml | 23 +++++++++++++++ .../workflows/close-issues-on-pr-merge.yml | 29 +++++++++++++++++++ .github/workflows/comment-on-issue-close.yml | 23 +++++++++++++++ .github/workflows/comment-on-pr-merge.yml | 24 +++++++++++++++ .github/workflows/label-issues-prs.yml | 26 +++++++++++++++++ 6 files changed, 143 insertions(+) create mode 100644 .github/workflows/auto-comment-issues.yml create mode 100644 .github/workflows/auto-comment-prs.yml create mode 100644 .github/workflows/close-issues-on-pr-merge.yml create mode 100644 .github/workflows/comment-on-issue-close.yml create mode 100644 .github/workflows/comment-on-pr-merge.yml create mode 100644 .github/workflows/label-issues-prs.yml diff --git a/.github/workflows/auto-comment-issues.yml b/.github/workflows/auto-comment-issues.yml new file mode 100644 index 0000000..7b67e9d --- /dev/null +++ b/.github/workflows/auto-comment-issues.yml @@ -0,0 +1,18 @@ +# .github/workflows/auto-comment-issues.yml +name: Auto Comment on Issues + +on: + issues: + types: [opened] + +jobs: + comment: + runs-on: ubuntu-latest + steps: + - name: Comment on issue + uses: peter-evans/commit-comment@v2 + with: + issue-number: ${{ github.event.issue.number }} + body: 'Thank you for opening this issue! We will get back to you soon.' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/auto-comment-prs.yml b/.github/workflows/auto-comment-prs.yml new file mode 100644 index 0000000..4590720 --- /dev/null +++ b/.github/workflows/auto-comment-prs.yml @@ -0,0 +1,23 @@ +# .github/workflows/auto-comment-prs.yml +name: Auto Comment on PR + +on: + pull_request: + types: [opened] + +jobs: + comment: + runs-on: ubuntu-latest + steps: + - name: Comment on PR + uses: actions/github-script@v5 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.payload.pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Thanks for the PR! We will review it shortly.' + }); + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/close-issues-on-pr-merge.yml b/.github/workflows/close-issues-on-pr-merge.yml new file mode 100644 index 0000000..e9a69e8 --- /dev/null +++ b/.github/workflows/close-issues-on-pr-merge.yml @@ -0,0 +1,29 @@ +# .github/workflows/close-issues-on-pr-merge.yml +name: Close Issues on PR Merge + +on: + pull_request: + types: [closed] + +jobs: + close-issues: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Close associated issues + uses: actions/github-script@v5 + with: + script: | + const issueNumbers = context.payload.pull_request.body.match(/#(\\d+)/g); + if (issueNumbers) { + for (const issue of issueNumbers) { + await github.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: parseInt(issue.replace('#', '')), + state: 'closed', + }); + } + } + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/comment-on-issue-close.yml b/.github/workflows/comment-on-issue-close.yml new file mode 100644 index 0000000..4fefcf4 --- /dev/null +++ b/.github/workflows/comment-on-issue-close.yml @@ -0,0 +1,23 @@ +# .github/workflows/comment-on-issue-close.yml +name: Comment on Issue Close + +on: + issues: + types: [closed] + +jobs: + comment: + runs-on: ubuntu-latest + steps: + - name: Comment on issue close + uses: actions/github-script@v5 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.payload.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'This issue has been closed. If you have further questions, feel free to open a new one.' + }); + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/comment-on-pr-merge.yml b/.github/workflows/comment-on-pr-merge.yml new file mode 100644 index 0000000..dcb9d0b --- /dev/null +++ b/.github/workflows/comment-on-pr-merge.yml @@ -0,0 +1,24 @@ +# .github/workflows/comment-on-pr-merge.yml +name: Comment on PR Merge + +on: + pull_request: + types: [closed] + +jobs: + comment: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Comment on merged PR + uses: actions/github-script@v5 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.payload.pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'The PR has been successfully merged. Thank you for your contribution!' + }); + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/label-issues-prs.yml b/.github/workflows/label-issues-prs.yml new file mode 100644 index 0000000..f32773b --- /dev/null +++ b/.github/workflows/label-issues-prs.yml @@ -0,0 +1,26 @@ +# .github/workflows/label-issues-prs.yml +name: Auto Label Issues and PRs + +on: + issues: + types: [opened] + pull_request: + types: [opened] + +jobs: + label: + runs-on: ubuntu-latest + steps: + - name: Add labels + uses: actions/github-script@v5 + with: + script: | + const labels = context.eventName === 'issues' ? ['bug'] : ['review']; + await github.issues.addLabels({ + issue_number: context.payload.issue.number || context.payload.pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: labels + }); + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}