Skip to content

Commit c6f3afb

Browse files
committed
feat: Add Branch Update Reminder as PR Comment
1 parent c79c799 commit c6f3afb

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

.github/workflows/lint.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ jobs:
1818
steps:
1919
- name: Checkout code
2020
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Ensure branch is up-to-date with main
25+
if: github.event_name == 'pull_request'
26+
run: |
27+
git fetch origin main
28+
if ! git merge-base --is-ancestor origin/main HEAD; then
29+
echo "❌ This branch is not up to date with main."
30+
exit 1
31+
fi
2132
2233
- name: Setup PHP
2334
uses: shivammathur/setup-php@v2
@@ -48,13 +59,38 @@ jobs:
4859
script: |
4960
const output = `
5061
## ⚠️ PHP Code Style Check Failed
51-
62+
5263
Please fix the code style issues found by Laravel Pint.
5364
Run \`composer lint\` locally to see and fix the issues.
54-
65+
5566
For more information about Laravel Pint, visit: https://laravel.com/docs/pint
5667
`;
57-
68+
69+
github.rest.issues.createComment({
70+
issue_number: context.issue.number,
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
body: output
74+
})
75+
76+
- name: Add Branch Update Reminder as PR Comment
77+
if: github.event_name == 'pull_request' && failure()
78+
uses: actions/github-script@v6
79+
with:
80+
github-token: ${{ secrets.GITHUB_TOKEN }}
81+
script: |
82+
const output = `
83+
## 🚨 Branch Update Required
84+
85+
This branch is outdated compared to \`main\`. Please update your branch by merging the latest changes from \`main\`.
86+
87+
Run the following command in your local branch:
88+
\`\`\`sh
89+
git pull origin main
90+
\`\`\`
91+
Then push the updated branch to the repository.
92+
`;
93+
5894
github.rest.issues.createComment({
5995
issue_number: context.issue.number,
6096
owner: context.repo.owner,

0 commit comments

Comments
 (0)