[WIP] Refactor duplicated code for improved maintainability #64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Library cat (optional) | |
| on: | |
| pull_request_target: | |
| types: [opened, reopened, synchronize, ready_for_review, edited] | |
| permissions: | |
| pull-requests: read | |
| jobs: | |
| library-cat: | |
| if: ${{ vars.ENABLE_LIBRARY_CAT == 'true' }} | |
| continue-on-error: true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = context.payload.pull_request | |
| const { data: commits } = await github.rest.pulls.listCommits({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: pr.number, | |
| per_page: 100, | |
| }) | |
| const bad = [] | |
| if (/\bWIP\b|fixup!|squash!/i.test(pr.title || '')) bad.push('title') | |
| if (commits.some(c => /\bWIP\b|fixup!|squash!/i.test(c.commit.message))) bad.push('commits') | |
| const msg = bad.length ? `Needs another look (${bad.join(', ')})` : 'Looks calm' | |
| core.summary | |
| .addHeading('Library cat') | |
| .addList([msg]) | |
| .write() | |
| if (bad.length) core.setFailed(msg) |