Skip to content

Commit a5a5e5d

Browse files
committed
Add pull_request.yml file
1 parent cdf9d34 commit a5a5e5d

File tree

2 files changed

+106
-45
lines changed

2 files changed

+106
-45
lines changed

.github/pull_request_template.md

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

.github/workflows/pull_request.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Pull Request Automation
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- dev
8+
types: [opened, synchronize, reopened, closed]
9+
10+
jobs:
11+
lint-and-test:
12+
runs-on: ubuntu-latest
13+
if: github.event_name == 'pull_request'
14+
15+
steps:
16+
- name: Checkout Code
17+
uses: actions/checkout@v3
18+
19+
# Set up Node.js for frontend
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: '18'
24+
25+
# Install dependencies for frontend
26+
- name: Install frontend dependencies
27+
working-directory: ./client
28+
run: npm install
29+
30+
# Run lint for frontend (React)
31+
- name: Run frontend lint
32+
working-directory: ./client
33+
run: npm run lint
34+
35+
# Run frontend tests (React)
36+
- name: Run frontend tests
37+
working-directory: ./client
38+
run: npm test
39+
40+
# Set up Go for backend
41+
- name: Setup Go
42+
uses: actions/setup-go@v4
43+
with:
44+
go-version: '1.20'
45+
46+
# Install Go dependencies
47+
- name: Install Go dependencies
48+
run: go mod tidy
49+
50+
# Run Go tests
51+
- name: Run Go tests
52+
run: go test ./...
53+
54+
# Label pull requests automatically based on the PR content or description
55+
add-labels:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Label PR based on content
59+
if: contains(github.event.pull_request.body, '🐛')
60+
uses: actions-ecosystem/action-add-labels@v1
61+
with:
62+
labels: 'bug'
63+
64+
- name: Label PR based on content
65+
if: contains(github.event.pull_request.body, '✨')
66+
uses: actions-ecosystem/action-add-labels@v1
67+
with:
68+
labels: 'feature'
69+
70+
- name: Label PR based on content
71+
if: contains(github.event.pull_request.body, '💥')
72+
uses: actions-ecosystem/action-add-labels@v1
73+
with:
74+
labels: 'breaking-change'
75+
76+
# Post checklist as comment on the PR
77+
post-checklist:
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Post Checklist
81+
uses: peter-evans/create-or-update-comment@v3
82+
with:
83+
token: ${{ secrets.GITHUB_TOKEN }}
84+
issue-number: ${{ github.event.pull_request.number }}
85+
body: |
86+
## 📝 Pull Request Checklist
87+
88+
- [ ] My code follows the style guidelines of this project
89+
- [ ] I have performed a self-review of my code
90+
- [ ] I have commented my code, particularly in hard-to-understand areas
91+
- [ ] I have made corresponding changes to the documentation
92+
- [ ] My changes generate no new warnings
93+
- [ ] I have added tests that prove my fix is effective or that my feature works
94+
- [ ] New and existing unit tests pass locally with my changes
95+
- [ ] Any dependent changes have been merged and published
96+
- [ ] I have updated the README if necessary
97+
98+
# Optional job to close the PR automatically if 'Closes #[issue_number]' is used
99+
close-related-issue:
100+
runs-on: ubuntu-latest
101+
if: github.event.pull_request.merged == true
102+
steps:
103+
- name: Close related issue
104+
uses: peter-evans/close-issue@v2
105+
with:
106+
issue-number: ${{ github.event.pull_request.body }}

0 commit comments

Comments
 (0)