-
-
Notifications
You must be signed in to change notification settings - Fork 108
52 lines (47 loc) · 1.63 KB
/
pr-semver-title.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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"