Skip to content

Commit

Permalink
Update Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
AnushkaChouhan25 committed Nov 5, 2024
1 parent 848db54 commit 9e5fca3
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/auto-comment-issues.yml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 23 additions & 0 deletions .github/workflows/auto-comment-prs.yml
Original file line number Diff line number Diff line change
@@ -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 }}
29 changes: 29 additions & 0 deletions .github/workflows/close-issues-on-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -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 }}
23 changes: 23 additions & 0 deletions .github/workflows/comment-on-issue-close.yml
Original file line number Diff line number Diff line change
@@ -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 }}
24 changes: 24 additions & 0 deletions .github/workflows/comment-on-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions .github/workflows/label-issues-prs.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 9e5fca3

Please sign in to comment.