name: sanity-check opened PRs on: # needs read/write GH token, do *not* execute arbitrary code from PR pull_request_target: types: [opened] jobs: check-pr: runs-on: ubuntu-latest steps: - name: Check Commit Message uses: actions/github-script@v3 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const { data: commits } = await github.pulls.listCommits({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.issue.number, }); console.log(commits[0].commit.message); // check first commit only (and only once) since later commits might be intended to be squashed away if (!/^(feat|fix|doc|style|refactor|test|chore|perf): .*[^.]($|\n\n)/.test(commits[0].commit.message)) { await github.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: 'Thanks for your contribution! Please make sure to follow our [Commit Convention](https://leanprover.github.io/lean4/doc/dev/commit_convention.html).', }); }