File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Version Bump Check
2
+
3
+ on :
4
+ pull_request :
5
+
6
+ env :
7
+ description : version update
8
+ file : main.go
9
+ regex : packageVersion\s+=\s+"\S+"
10
+
11
+ jobs :
12
+ main :
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+ - name : Check Out Code
16
+ uses : actions/checkout@v4
17
+ with :
18
+ fetch-depth : -1
19
+
20
+ - id : changes
21
+ name : Check for Changes
22
+ run : |
23
+ changed_file="$(git diff ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} ${{ env.file }})"
24
+ if [ -z "$changed_file" ]; then
25
+ exit 1
26
+ else
27
+ added_match=$(echo "$changed_file" | grep -E '^\+\s+${{ env.regex }}')
28
+ removed_match=$(echo "$changed_file" | grep -E '^\-\s+${{ env.regex }}')
29
+ if [[ -n "$added_match" ]] && [[ -n "$removed_match" ]]; then
30
+ echo "added_match=$added_match" >> $GITHUB_OUTPUT
31
+ echo "removed_match=$removed_match" >> $GITHUB_OUTPUT
32
+ else
33
+ exit 1
34
+ fi
35
+ fi
36
+
37
+ - if : success()
38
+ name : Found Change Comment
39
+ uses : thollander/actions-comment-pull-request@v2
40
+ with :
41
+ comment_tag : changes
42
+ message : |
43
+ :white_check_mark: Found ${{ env.description }} in `${{ env.file }}`:
44
+
45
+ ```diff
46
+ ${{ steps.changes.outputs.removed_match }}
47
+ ${{ steps.changes.outputs.added_match }}
48
+ ```
49
+
50
+ - if : failure()
51
+ name : Missing Change Comment
52
+ uses : thollander/actions-comment-pull-request@v2
53
+ with :
54
+ comment_tag : changes
55
+ message : |
56
+ :warning: Could not find ${{ env.description }} in `${{ env.file }}`
You can’t perform that action at this time.
0 commit comments