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

GitActions Fixed #558

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions .github/workflows/issue_open_close.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: Issue Auto Comment

# Created by @smog-root

on:
issues:
types: [opened, closed]

jobs:
comment:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add a comment when an issue is opened
if: github.event.action == 'opened'
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
issue_number: ${{ github.event.issue.number }}
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! πŸš€
"
number: ${{ github.event.issue.number }}
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! πŸš€

- name: Add a comment when an issue is closed
if: github.event.action == 'closed'
uses: actions-ecosystem/action-create-comment@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
issue_number: ${{ github.event.issue.number }}
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! πŸš€"
number: ${{ github.event.issue.number }}
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! πŸš€
78 changes: 35 additions & 43 deletions .github/workflows/pr-checker.yaml
Original file line number Diff line number Diff line change
@@ -1,57 +1,49 @@
name: PR Issue Checker
# Created by @smog-root.
name: PR Checker

on:
pull_request:
types: [opened, edited]
types: [opened, synchronize]

jobs:
check_pr_details:
check-pr:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies (if needed)
run: pip install re # Install Python's regex library (not needed if using built-in)

- name: Check PR Description and Title
id: check_pr_details
id: check_pr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python -c "
import re
import sys
import os

pr_description = os.getenv('GITHUB_EVENT_PULL_REQUEST_BODY', '')
pr_title = os.getenv('GITHUB_EVENT_PULL_REQUEST_TITLE', '')

# Check if PR description is present
if not pr_description:
print('PR description is missing.')
sys.exit(1)

# Check if the PR description contains 'Fixes #<issue-number>'
if not re.search(r'Fixes #[0-9]+', pr_description):
print('The PR description should include Fixes #<issue-number>.')
sys.exit(1)

# Check if the PR title starts with FIX, FEAT, or DOC
if not re.match(r'^(FIX|FEAT|DOC)', pr_title):
print('The PR title should start with FIX, FEAT, or DOC.')
sys.exit(1)

print('PR description and title are valid.')
"
env:
GITHUB_EVENT_PULL_REQUEST_BODY: ${{ github.event.pull_request.body }}
GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
import re
import sys
import os

pr_description = os.getenv('GITHUB_EVENT_PULL_REQUEST_BODY', '')
pr_title = os.getenv('GITHUB_EVENT_PULL_REQUEST_TITLE', '')

# Check if PR description is present
if not pr_description:
print('Warning: PR description is missing.')
else:
# Check if the PR description contains 'Fixes #<issue-number>'
if not re.search(r'Fixes #[0-9]+', pr_description):
print('Error: The PR description should include Fixes #<issue-number>.')
sys.exit(1)

# Check if the PR title starts with FIX, FEAT, or DOC
if not re.match(r'^(FIX|FEAT|DOC)', pr_title):
print('Error: The PR title should start with FIX, FEAT, or DOC.')
sys.exit(1)

print('PR description and title are valid.')
"

- name: Output result
run: echo "All checks passed."

run: |
if [ -s "${{ steps.check_pr.outputs.stderr }}" ]; then
echo "All checks passed."
else
echo "There were errors during the PR check."
Loading