Skip to content

Commit 77ed74b

Browse files
authored
Merge pull request #1461 from vansh-codes/leetcodeQ945
Added Leetcode Q945 #1409
2 parents 716508a + 7d94375 commit 77ed74b

21 files changed

+3133
-3375
lines changed
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +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@v7
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
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@v7
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
2929
});

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

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +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
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
3737
done

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

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +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@v9
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
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@v9
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
3434
debug-only: false

0 commit comments

Comments
 (0)