-
Notifications
You must be signed in to change notification settings - Fork 8
36 lines (31 loc) · 1.3 KB
/
pr-check-validate.yaml
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
name: Check PR Info and Validate
on:
pull_request:
types: [opened, synchronize, reopened] #opened:当新Pull Request创建时触发,synchronize表示当已有Pull Request的源分支有新的提交时触发,reopened表示当被关闭的Pull Request重新打开时触发
jobs:
check-pr-info-and-validate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# 获取PR信息并将其添加到环境变量
- name: set PR_INFO
run: |
echo PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') >> $GITHUB_ENV
echo PR_TITLE=$(jq --raw-output .pull_request.title "$GITHUB_EVENT_PATH") >> $GITHUB_ENV
echo PR_URL=$(jq --raw-output .pull_request.html_url "$GITHUB_EVENT_PATH") >> $GITHUB_ENV
echo PR_USER=$(jq --raw-output .pull_request.user.login "$GITHUB_EVENT_PATH") >> $GITHUB_ENV
- name: Print Variables
run: |
echo PR_NUMBER=$PR_NUMBER
echo PR_TITLE=$PR_TITLE
echo PR_URL=$PR_URL
echo PR_USER=$PR_USER
- name: Validate Title Check
run: |
if grep -q '#[0-9]\+' <<< "$PR_TITLE"; then
echo "Title contains '#'"
else
echo "Title does not contain '#'"
exit 1
fi