-
Notifications
You must be signed in to change notification settings - Fork 1
53 lines (45 loc) · 1.37 KB
/
check_version.yml
File metadata and controls
53 lines (45 loc) · 1.37 KB
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
53
name: Check Version Updated
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
env:
target_branch: ${{ github.base_ref || 'master' }}
jobs:
check_version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Fetch target branch
run: |
git fetch origin ${{ env.target_branch }}
- name: Diff version.txt
run: |
echo "Current directory: $(pwd)"
modified_files=$(git diff --name-only origin/${{ env.target_branch }}...HEAD | grep version.txt)
echo "Modified files: $modified_files"
if [[ ! -n $modified_files ]]; then
echo "version.txt unchanged"
exit 1
else
echo "version.txt changed"
fi
- name: Add PR review comment if version.txt is not updated
if: failure() && !cancelled()
uses: actions/github-script@v4
with:
script: |
const { pull_request } = context.payload;
const comment = "代码改动同时请更新版本文件 version.txt";
await github.issues.createComment({
issue_number: pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});