6.4.7-rc2 #36
This file contains 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: Check PR title for proper semver | |
on: | |
pull_request: | |
branches: | |
- beta | |
- stable | |
workflow_dispatch: | |
inputs: | |
pr_number: | |
description: "Pull request number to check" | |
required: true | |
type: number | |
jobs: | |
check-pr-semver-title: | |
runs-on: ubuntu-latest | |
name: Validate PR Title | |
steps: | |
- name: Get PR details | |
id: find_pr | |
run: | | |
if [ -z "${{ github.event.inputs.pr_number }}" ]; then | |
prNumber=${{ github.event.pull_request.number }} | |
else | |
prNumber=${{ github.event.inputs.pr_number }} | |
fi | |
echo "prNumber=$prNumber" | tee /dev/stderr >> "$GITHUB_OUTPUT" | |
- name: Fetch pull request title | |
id: pr_title | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); | |
const prNumber = ${{ steps.find_pr.outputs.prNumber }}; | |
const { data: pull_request } = await github.rest.pulls.get({ | |
owner: owner, | |
repo: repo, | |
pull_number: prNumber | |
}); | |
return pull_request.title; | |
- name: Check PR title format | |
run: | | |
version="${{ steps.pr_title.outputs.result }}" | |
if ! [[ "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then | |
echo "Invalid semver: '$version'!" | |
exit 1 | |
fi | |
echo "Version is proper semver: $version" | |