|
| 1 | +name: Pull request checks |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + types: |
| 5 | + - opened |
| 6 | + - reopened |
| 7 | + - synchronize |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + style_check: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Install |
| 19 | + uses: pnpm/action-setup@v4 |
| 20 | + with: |
| 21 | + version: latest |
| 22 | + run_install: true |
| 23 | + |
| 24 | + - name: Lint code |
| 25 | + run: | |
| 26 | + pnpm run lint:tsc |
| 27 | + pnpm run lint:eslint |
| 28 | +
|
| 29 | + - name: Lint commits |
| 30 | + if: github.event_name == 'pull_request' |
| 31 | + run: | |
| 32 | + commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose |
| 33 | +
|
| 34 | + notify_success: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + needs: style_check |
| 37 | + |
| 38 | + if: success() |
| 39 | + steps: |
| 40 | + - name: Comment success |
| 41 | + uses: actions/github-script@v7 |
| 42 | + with: |
| 43 | + script: | |
| 44 | + const body = `### ✅ Successful Review |
| 45 | +
|
| 46 | + Great news! Your pull request has been successfully reviewed, and no errors were found. |
| 47 | +
|
| 48 | + ### ⏳ Next Steps |
| 49 | +
|
| 50 | + The author will review the changes shortly, and we look forward to merging your contributions into the project. Thank you for your hard work and dedication! 🎉` |
| 51 | + |
| 52 | + github.rest.issues.createComment({ |
| 53 | + owner: context.repo.owner, |
| 54 | + repo: context.repo.repo, |
| 55 | + issue_number: context.issue.number, |
| 56 | + body |
| 57 | + }); |
| 58 | + |
| 59 | + github.rest.issues.addLabels({ |
| 60 | + owner: context.repo.owner, |
| 61 | + repo: context.repo.repo, |
| 62 | + issue_number: context.issue.number, |
| 63 | + labels: ["ci-success"] |
| 64 | + }); |
| 65 | + notify_failure: |
| 66 | + runs-on: ubuntu-latest |
| 67 | + needs: style_check |
| 68 | + if: failure() |
| 69 | + steps: |
| 70 | + - name: Comment failure |
| 71 | + uses: actions/github-script@v7 |
| 72 | + with: |
| 73 | + script: | |
| 74 | + const body = `### ⚠️ Review Required |
| 75 | +
|
| 76 | + Thank you for your contribution! Upon review, we've identified some issues in the pull request that need to be addressed. Please take a moment to review the errors and make the necessary adjustments before we can proceed with the integration. |
| 77 | +
|
| 78 | + ### 🛠️ Next Steps |
| 79 | +
|
| 80 | + Feel free to reach out if you have any questions or need assistance. We appreciate your effort in improving our codebase! 🙏` |
| 81 | + |
| 82 | + github.rest.issues.createComment({ |
| 83 | + owner: context.repo.owner, |
| 84 | + repo: context.repo.repo, |
| 85 | + issue_number: context.issue.number, |
| 86 | + body |
| 87 | + }); |
| 88 | +
|
| 89 | + github.rest.issues.addLabels({ |
| 90 | + owner: context.repo.owner, |
| 91 | + repo: context.repo.repo, |
| 92 | + issue_number: context.issue.number, |
| 93 | + labels: ["ci-failure"] |
| 94 | + }); |
0 commit comments