Skip to content

Commit 8102b9e

Browse files
committed
resolved conflicts
2 parents f93f987 + 4b85b89 commit 8102b9e

14 files changed

+688
-284
lines changed

.github/workflows/auto-comment-on-close.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/auto-comment-pr-merge.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/greetings.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Issue Auto Comment
2+
3+
# Created by @smog-root
4+
5+
on:
6+
issues:
7+
types: [opened, closed]
8+
9+
jobs:
10+
comment:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Add a comment when an issue is opened
14+
if: github.event.action == 'opened'
15+
uses: actions-ecosystem/action-create-comment@v1
16+
with:
17+
github_token: ${{ secrets.GITHUB_TOKEN }}
18+
issue_number: ${{ github.event.issue.number }}
19+
body: "👋 Thanks for opening this issue! We appreciate your contribution. Please make sure you’ve provided all the necessary details and screenshots, and don't forget to follow our Guidelines and Code of Conduct. Happy coding! 🚀
20+
"
21+
22+
- name: Add a comment when an issue is closed
23+
if: github.event.action == 'closed'
24+
uses: actions-ecosystem/action-create-comment@v1
25+
with:
26+
github_token: ${{ secrets.GITHUB_TOKEN }}
27+
issue_number: ${{ github.event.issue.number }}
28+
body: " ✅ This issue has been successfully closed. Thank you for your contribution and helping us improve the project! If you have any more ideas or run into other issues, feel free to open a new one. Happy coding! 🚀"

.github/workflows/pr-checker.yml

Lines changed: 83 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,91 @@
1-
name: PR Issue Checker
2-
# Created my @smog-root.
1+
name: PR Validation
2+
3+
# Created by smog-root
4+
35
on:
46
pull_request:
57
types: [opened, edited]
68

79
jobs:
8-
check_pr_description:
10+
validate-pr:
911
runs-on: ubuntu-latest
1012

1113
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v2
14-
15-
- name: Check PR Description
16-
id: check_pr_description
17-
run: |
18-
PR_DESCRIPTION="${{ github.event.pull_request.body }}"
19-
if [[ -z "$PR_DESCRIPTION" ]]; then
20-
echo "PR description is missing."
21-
exit 1
22-
fi
23-
24-
if [[ ! "$PR_DESCRIPTION" =~ Fixes\ #[0-9]+ ]]; then
25-
echo "The PR description should include 'Fixes #<issue-number>' if not addressing any issue."
26-
echo "##[error]Fixes #NEW must be included in the description."
27-
exit 1
28-
fi
29-
30-
echo "PR description is valid."
31-
32-
- name: Output result
33-
run: echo "All checks passed."
14+
- name: Check out code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '14'
21+
22+
- name: Validate PR Description
23+
id: pr-check
24+
run: |
25+
# Fetch PR information
26+
PR_DESCRIPTION=$(jq -r .pull_request.body < "$GITHUB_EVENT_PATH")
27+
PR_TITLE=$(jq -r .pull_request.title < "$GITHUB_EVENT_PATH")
28+
29+
# Define file paths for the output variables
30+
PR_VALID_FILE=$(mktemp)
31+
ERROR_MESSAGE_FILE=$(mktemp)
32+
SUCCESS_MESSAGE_FILE=$(mktemp)
33+
34+
# Default value for PR_VALID
35+
PR_VALID="true"
36+
37+
# Check if PR description is empty
38+
if [ -z "$PR_DESCRIPTION" ] || [ "$PR_DESCRIPTION" == "null" ]; then
39+
echo "Empty PR description"
40+
PR_VALID="false"
41+
echo '❌ Error: PR description is empty!' > "$ERROR_MESSAGE_FILE"
42+
fi
43+
44+
# Check for issue reference in the description
45+
ISSUE_PATTERN="(Fixes|Close|Closes|Closed|Fix|Fixed|Resolve|Resolves) #[0-9]+"
46+
if [[ ! "$PR_DESCRIPTION" =~ $ISSUE_PATTERN ]]; then
47+
echo "Invalid or missing issue reference"
48+
PR_VALID="false"
49+
echo '❌ Error: PR must reference an issue with the format Fixes ,Close ,Closes ,Closed ,Fix ,Fixed ,Resolve ,Resolves #Issue_Number' > "$ERROR_MESSAGE_FILE"
50+
fi
51+
52+
# If both checks pass
53+
if [ "$PR_VALID" == "true" ]; then
54+
echo '✅ Success: PR is valid!' > "$SUCCESS_MESSAGE_FILE"
55+
fi
56+
57+
# Save the outputs to environment files
58+
echo "PR_VALID=$PR_VALID" >> $GITHUB_ENV
59+
echo "ERROR_MESSAGE=$(cat $ERROR_MESSAGE_FILE)" >> $GITHUB_ENV
60+
echo "SUCCESS_MESSAGE=$(cat $SUCCESS_MESSAGE_FILE)" >> $GITHUB_ENV
61+
62+
- name: Post comment on PR
63+
uses: actions/github-script@v6
64+
with:
65+
github-token: ${{ secrets.GITHUB_TOKEN }}
66+
script: |
67+
const prValid = process.env.PR_VALID;
68+
const errorMessage = process.env.ERROR_MESSAGE;
69+
const successMessage = process.env.SUCCESS_MESSAGE;
70+
const prNumber = context.payload.pull_request.number;
71+
72+
if (prValid === 'false') {
73+
github.rest.issues.createComment({
74+
issue_number: prNumber,
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
body: errorMessage
78+
});
79+
core.setFailed(errorMessage);
80+
} else {
81+
github.rest.issues.createComment({
82+
issue_number: prNumber,
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
body: successMessage
86+
});
87+
}
88+
89+
- name: Fail if validation failed
90+
if: env.PR_VALID == 'false'
91+
run: exit 1

.github/workflows/pr_merge.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Merge Thank You
2+
3+
# Created by @smog-root
4+
5+
on:
6+
pull_request_target:
7+
types: [closed] # Trigger when a PR is closed
8+
9+
permissions:
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
post_merge_message:
15+
if: github.event.pull_request.merged == true # Only run if the PR was merged
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Post thank you message
20+
uses: actions/github-script@v7
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }} # Ensure token is used
23+
script: |
24+
const prNumber = context.payload.pull_request.number;
25+
const owner = context.repo.owner;
26+
const repo = context.repo.repo;
27+
28+
// Post a thank you message upon PR merge
29+
await github.rest.issues.createComment({
30+
owner: owner,
31+
repo: repo,
32+
issue_number: prNumber,
33+
body: `🎉🎉 Thank you for your contribution! Your PR #${prNumber} has been merged! 🎉🎉`
34+
});

.github/workflows/pr_raise.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Auto Comment on PR
2+
3+
# Created by @smog-root
4+
5+
on:
6+
pull_request_target:
7+
types: [opened]
8+
9+
permissions:
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
comment:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
pull-requests: write
18+
steps:
19+
- name: Add Comment to Pull Request
20+
run: |
21+
COMMENT=$(cat <<EOF
22+
{
23+
"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 chaotic [CONTRIBUTING.md](https://github.com/vansh-codes/ChaosWeb/blob/main/CONTRIBUTING). If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊"
24+
}
25+
EOF
26+
)
27+
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
28+
-X POST \
29+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
30+
-H "Accept: application/vnd.github.v3+json" \
31+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
32+
-d "$COMMENT")
33+
cat response.json
34+
if [ "$RESPONSE" -ne 201 ]; then
35+
echo "Failed to add comment"
36+
exit 1
37+
fi
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 BitBox
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)