Skip to content

Commit

Permalink
CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
piyushg-07 committed Jun 6, 2024
1 parent e3df15f commit 912856c
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

## Related Issue
[Cite any related issue(s) this pull request addresses. If none, simply state “None”]

## Description
[Please include a brief description of the changes or features added]

## Type of PR

- [ ] Bug fix
- [ ] Feature enhancement
- [ ] Documentation update
- [ ] Other (specify): _______________

## Screenshots / videos (if applicable)
[Attach any relevant screenshots or videos demonstrating the changes]

## Checklist:
- [ ] I have performed a self-review of my code
- [ ] I have read and followed the Contribution Guidelines.
- [ ] I have tested the changes thoroughly before submitting this pull request.
- [ ] I have provided relevant issue numbers, screenshots, and videos after making the changes.
- [ ] I have commented my code, particularly in hard-to-understand areas.
<!-- [X] - put a cross/X inside [] to check the box -->

## Additional context:
[Include any additional information or context that might be helpful for reviewers.]
43 changes: 43 additions & 0 deletions .github/workflows/PR-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- Pull Request Template -->

## Related Issue\*

Closes #issue_number

<!-- If there is no issue number, the PR will not be merged. Therefore, please ensure that the issue number is added -->

## Description

<!-- Write a brief description of the changes made in the PR. Explain the problem being addressed, or any relevant
information. -->

## Screenshot Section

<!-- Include the screenshot to preview the changes done and their proper functionality -->

## Demo Video Section\*

<!-- Include the demo video to preview the changes done and their proper functionality -->

## Checklist

<!-- [x] - To mark checked, put 'x' in place of ' '(space) -->
<!-- [ ] - Keep unchecked using ' '(space) -->

- [ ] I have attached screenshot in screenshot section
- [ ] I have added video

## Task

- [ ] Follow Us On social media - <a href="https://www.linkedin.com/in/rathashutosh/" target="_blank">LinkedIn</a> <a href="https://twitter.com/v_ashu_dev" target="_blank">Twitter</a>
Let's connect
- [ ] <a href="https://github.com/ashutosh-rath02" target="_blank">GitHub</a>

## Enter you User Id's:

LinkedIn:
<br>GitHub:
<br>Discord:

If you Follow us in both social medias we provide 'level2'
\*Only First time
29 changes: 29 additions & 0 deletions .github/workflows/autocomment-iss-close.yml
Original file line number Diff line number Diff line change
@@ -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.MY_SECRET_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
});
46 changes: 46 additions & 0 deletions .github/workflows/close-old-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Close Old Issues

on:
schedule:
- cron: "0 0 * * *" # Runs daily at midnight

jobs:
close-issues:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Close Old Issues
env:
GITHUB_TOKEN: ${{ secrets.MY_SECRET_TOKEN }}
run: |
# Fetch open issues
open_issues=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/issues?state=open&per_page=100" \
| jq -r '.[] | select(.pull_request == null) | .number')
for issue in $open_issues; do
# Get the last updated timestamp of the issue
last_updated=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue" \
| jq -r '.updated_at')
# Calculate days since the last update
days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 ))
if [ $days_since_update -gt 30 ]; then
# Close the issue
curl -s -X PATCH -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"state":"closed"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue"
# Add a comment explaining why the issue was closed
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"body":"This issue has been automatically closed because it has been inactive for more than 30 days. If you believe this is still relevant, feel free to reopen it or create a new one. Thank you!"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue/comments"
fi
done
32 changes: 32 additions & 0 deletions .github/workflows/close-old-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Close Stale PRs

on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
pull_request:
types:
- opened
- reopened
- synchronize

permissions:
pull-requests: write
issues: write

jobs:
close_stale_prs:
runs-on: ubuntu-latest
steps:
- name: Close Stale PRs
uses: actions/stale@v7
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR has been automatically closed due to inactivity from the owner for 15 days.'
days-before-pr-stale: 15
days-before-pr-close: 1
exempt-pr-author: false
exempt-pr-labels: ''
only-labels: ''
operations-per-run: 30
remove-stale-when-updated: true
debug-only: false
17 changes: 17 additions & 0 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Development CI/CD

on:
pull_request:
branches: [dev]
types: [opened, synchronize, reopened, edited, ready_for_review]

jobs:
prettier:
uses: ./.github/workflows/prettier.yml
with:
fail-on-error: true

eslint:
uses: ./.github/workflows/eslint.yml
with:
fail-on-error: true

0 comments on commit 912856c

Please sign in to comment.