Skip to content

Commit policy / PR 15 #225

Commit policy / PR 15

Commit policy / PR 15 #225

name: Conventional Commits
run-name: Commit policy / ${{ github.event_name == 'pull_request' && format('PR {0}', github.event.pull_request.number) || github.ref_name }}
on:
pull_request:
types: [opened, edited, synchronize, reopened, ready_for_review]
push:
branches: [main]
permissions:
contents: read
pull-requests: read
concurrency:
group: conventional-commits-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
PREK_VERSION: 0.3.10
jobs:
conventional:
name: Validate commit and PR title
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}
persist-credentials: false
- name: Set up Rust tooling
uses: ./.github/actions/setup-rust-tools
with:
tools: prek@${{ env.PREK_VERSION }}
- name: Check PR title
if: github.event_name == 'pull_request'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
printf '%s\n' "${PR_TITLE}" > "${RUNNER_TEMP}/pr-title.txt"
scripts/validate.sh commit-msg "${RUNNER_TEMP}/pr-title.txt"
- name: Check release intent for package changes
if: github.event_name == 'pull_request'
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_BRANCH: ${{ github.event.pull_request.head.ref }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: ./.github/scripts/check-release-intent.sh "$PR_TITLE" "$BASE_SHA" "$HEAD_SHA" "$HEAD_BRANCH"
- name: Check HEAD commit subject
run: |
git log -1 --pretty=%s > "${RUNNER_TEMP}/head-commit.txt"
scripts/validate.sh commit-msg "${RUNNER_TEMP}/head-commit.txt"