-
Notifications
You must be signed in to change notification settings - Fork 62
82 lines (75 loc) · 2.92 KB
/
pr.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Check PR
on:
pull_request:
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v44
with:
files_ignore: |
README.md
ci/**
.github/**
- name: List all changed files
id: list_changed_files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
ALL_MODIFIED_FILES_COUNT: ${{ steps.changed-files.outputs.all_modified_files_count }}
run: |
echo "${ALL_MODIFIED_FILES_COUNT} files"
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
- name: auto_pass
if: steps.changed-files.outputs.all_modified_files_count == '0'
id: check_if_only_ignored
run: |
echo "Version bump not required." # This will be used to set a label later
- name: Get version from file
if: steps.changed-files.outputs.all_modified_files_count != '0'
id: get_version
run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
- name: 'Get Previous tag'
if: steps.changed-files.outputs.all_modified_files_count != '0'
id: previoustag
uses: "WyriHaximus/[email protected]"
- name: Checking for version bump
if: steps.changed-files.outputs.all_modified_files_count != '0'
id: check_vbump
run: |
LAST_TAG="${{ steps.previoustag.outputs.tag }}"
NEW_TAG="v${{ steps.get_version.outputs.version }}"
RESULT=$(ci/assets/checksemver.sh ${NEW_TAG} ${LAST_TAG})
if [ "${RESULT}" == "1" ]; then
echo "Version bump found." # This will be used to set a label later
elif [ "${RESULT}" == "0" ]; then
echo "Version bump did not happen. ${LAST_TAG} is the same as ${NEW_TAG}" # This will be used to set a label later
exit 1
else
echo "Version bump did not happen. ${LAST_TAG} is higher than ${NEW_TAG}" # This will be used to set a label later
exit 1
fi
- name: Add PR Label
if: always()
uses: actions/github-script@v6
with:
script: |
const message = '${{ steps.check_if_only_ignored.outputs.msg || steps.check_vbump.outputs.msg }}';
const label = message.includes("Version bump not required") ? "no version bump required" :
message.includes("Version bump found") ? "version bump" :
"version bump error";
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label]
});