Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD CICD Workflows for GITHUB Automation #95

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Loading