diff --git a/pr-title-check/README.md b/pr-title-check/README.md new file mode 100644 index 0000000..b17c64c --- /dev/null +++ b/pr-title-check/README.md @@ -0,0 +1,29 @@ +# `pr-title-check` GitHub Action + +This action validates pull request titles by checking them for typos (using [typos](https://github.com/crate-ci/typos)) and verifying they follow the [Conventional Commits](https://www.conventionalcommits.org/) format (using [action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request)). + +The action checks out the repository so that any `_typos.toml` configuration present in the repo is respected. + +## Usage + +```yaml +name: CI (PR) + +on: + pull_request: + +permissions: + contents: read + pull-requests: read + +jobs: + pr-title-check: + name: PR title check + runs-on: ubuntu-latest + steps: + - uses: apify/actions/pr-title-check@main +``` + +### Inputs + +- `github-token` (optional, default `${{ github.token }}`) — Token used by the semantic PR title check to read PR metadata via the GitHub API. diff --git a/pr-title-check/action.yaml b/pr-title-check/action.yaml new file mode 100644 index 0000000..b3e295c --- /dev/null +++ b/pr-title-check/action.yaml @@ -0,0 +1,30 @@ +name: "PR title check" +description: "Check PR title for typos and conventional commit format" + +inputs: + github-token: + description: "GitHub token for the semantic PR title check" + required: false + default: ${{ github.token }} + +runs: + using: "composite" + steps: + # Needed to access `_typos.toml` from the repository + - uses: actions/checkout@v4 + + - name: Write PR title to file + shell: bash + run: echo "$PR_TITLE" > /tmp/pr-title.txt + env: + PR_TITLE: ${{ github.event.pull_request.title }} + + - name: Spell-check PR title + uses: crate-ci/typos@master + with: + files: /tmp/pr-title.txt + + - name: Check PR title follows conventional commits + uses: amannn/action-semantic-pull-request@v6.1.1 + env: + GITHUB_TOKEN: ${{ inputs.github-token }}