|
18 | 18 | steps: |
19 | 19 | - name: Checkout code |
20 | 20 | 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 |
21 | 32 |
|
22 | 33 | - name: Setup PHP |
23 | 34 | uses: shivammathur/setup-php@v2 |
@@ -48,13 +59,38 @@ jobs: |
48 | 59 | script: | |
49 | 60 | const output = ` |
50 | 61 | ## ⚠️ PHP Code Style Check Failed |
51 | | - |
| 62 | +
|
52 | 63 | Please fix the code style issues found by Laravel Pint. |
53 | 64 | Run \`composer lint\` locally to see and fix the issues. |
54 | | - |
| 65 | +
|
55 | 66 | For more information about Laravel Pint, visit: https://laravel.com/docs/pint |
56 | 67 | `; |
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 | +
|
58 | 94 | github.rest.issues.createComment({ |
59 | 95 | issue_number: context.issue.number, |
60 | 96 | owner: context.repo.owner, |
|
0 commit comments