Skip to content
This repository was archived by the owner on Jun 8, 2025. It is now read-only.

Commit 233501b

Browse files
authored
Merge pull request #3 from Asymtode712/new
Added multiple workflow as discussed
2 parents e81aaad + 7aa88b7 commit 233501b

File tree

6 files changed

+209
-0
lines changed

6 files changed

+209
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Auto Comment on PR
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
comment:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
pull-requests: write
16+
steps:
17+
- name: Add Comment to Pull Request
18+
run: |
19+
COMMENT=$(cat <<EOF
20+
{
21+
"body": "Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our [CONTRIBUTING.md](https://github.com/recodehive/recode-hive-website/blob/main/CONTRIBUTING.md). If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊"
22+
}
23+
EOF
24+
)
25+
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
26+
-X POST \
27+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
28+
-H "Accept: application/vnd.github.v3+json" \
29+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
30+
-d "$COMMENT")
31+
cat response.json
32+
if [ "$RESPONSE" -ne 201 ]; then
33+
echo "Failed to add comment"
34+
exit 1
35+
fi
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Comment on Issue Close
2+
3+
on:
4+
issues:
5+
types: [closed]
6+
7+
jobs:
8+
greet-on-close:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
steps:
13+
- name: Greet User
14+
uses: actions/github-script@v5
15+
with:
16+
github-token: ${{ secrets.GITHUB_TOKEN }}
17+
script: |
18+
const issue = context.payload.issue;
19+
const issueCreator = issue.user.login;
20+
const issueNumber = issue.number;
21+
22+
const greetingMessage = `Hello @${issueCreator}! Your issue #${issueNumber} has been closed. Thank you for your contribution!`;
23+
24+
github.rest.issues.createComment({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
issue_number: issueNumber,
28+
body: greetingMessage
29+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Auto Comment on Issue
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
comment:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
issues: write
15+
steps:
16+
- name: Add Comment to Issue
17+
run: |
18+
COMMENT=$(cat <<EOF
19+
{
20+
"body": "Thank you for creating this issue! 🎉 We'll look into it as soon as possible. In the meantime, please make sure to provide all the necessary details and context. If you have any questions or additional information, feel free to add them here. Your contributions are highly appreciated! 😊\n\nYou can also check our [CONTRIBUTING.md](https://github.com/recodehive/recode-hive-website/blob/main/CONTRIBUTING.md) for guidelines on contributing to this project."
21+
}
22+
EOF
23+
)
24+
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
25+
-X POST \
26+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
27+
-H "Accept: application/vnd.github.v3+json" \
28+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
29+
-d "$COMMENT")
30+
cat response.json
31+
if [ "$RESPONSE" -ne 201 ]; then
32+
echo "Failed to add comment"
33+
exit 1
34+
fi
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Auto Comment on PR Merge
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
issues: write
9+
pull-requests: write
10+
11+
jobs:
12+
comment:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
pull-requests: write
16+
if: github.event.pull_request.merged == true
17+
18+
steps:
19+
- name: Checkout Repository
20+
uses: actions/checkout@v2
21+
22+
- name: Add Comment to Issue
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
run: |
26+
COMMENT=$(cat <<EOF
27+
{
28+
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀"
29+
}
30+
EOF
31+
)
32+
curl -X POST \
33+
-H "Authorization: Bearer $GITHUB_TOKEN" \
34+
-H "Accept: application/vnd.github.v3+json" \
35+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
36+
-d "$COMMENT"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Close Old Issues
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
6+
jobs:
7+
close-issues:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout Repository
12+
uses: actions/checkout@v4
13+
14+
- name: Close Old Issues
15+
run: |
16+
open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
17+
"https://api.github.com/repos/${{ github.repository }}/issues?state=open" \
18+
| jq -r '.[] | .number')
19+
for issue in $open_issues; do
20+
# Get the last updated timestamp of the issue
21+
last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
22+
"https://api.github.com/repos/${{ github.repository }}/issues/$issue" \
23+
| jq -r '.updated_at')
24+
days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 ))
25+
if [ $days_since_update -gt 30 ]; then
26+
curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
27+
-H "Accept: application/vnd.github.v3+json" \
28+
-d '{"state":"closed"}' \
29+
"https://api.github.com/repos/${{ github.repository }}/issues/$issue"
30+
31+
# Add a comment explaining when the issue will be closed
32+
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
33+
-H "Accept: application/vnd.github.v3+json" \
34+
-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!"}' \
35+
"https://api.github.com/repos/${{ github.repository }}/issues/$issue/comments"
36+
fi
37+
done

.github/workflows/close-old-pr.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Close Stale PRs
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Runs daily at midnight
6+
pull_request:
7+
types:
8+
- opened
9+
- reopened
10+
- synchronize
11+
12+
permissions:
13+
pull-requests: write
14+
issues: write
15+
16+
jobs:
17+
close_stale_prs:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
pull-requests: write
21+
22+
steps:
23+
- uses: actions/stale@v7
24+
with:
25+
repo-token: ${{ secrets.GITHUB_TOKEN }}
26+
stale-pr-message: 'This PR has been automatically closed due to inactivity from the owner for 15 days.'
27+
days-before-pr-stale: 15
28+
days-before-pr-close: 0
29+
exempt-pr-author: false
30+
exempt-pr-labels: ''
31+
only-labels: ''
32+
operations-per-run: 30
33+
remove-stale-when-updated: true
34+
debug-only: false

0 commit comments

Comments
 (0)