@@ -2,26 +2,55 @@ name: Gradle Publish [snapshot]
2
2
3
3
on :
4
4
workflow_dispatch :
5
+ schedule :
6
+ - cron : " 0 15 * * 5" # friday 15:00 UTC
5
7
6
8
jobs :
7
9
check-branch :
8
10
runs-on : ubuntu-latest
9
11
steps :
10
12
- name : Check Branch
11
- if : github.ref != 'refs/heads/main'
13
+ if : startsWith( github.ref, 'refs/heads/')
12
14
run : |
13
- echo "::error title=wrong branch selected::this workflow must be run on the 'main' branch "
14
- exit 1
15
-
16
- publish-snapshot :
17
- needs : check-branch
15
+ BRANCH="${GITHUB_REF#refs/heads/} "
16
+ if [[ "$BRANCH" != "main" && "$BRANCH" != release/* ]]; then
17
+ echo "::error title=wrong branch selected::this workflow must be run on 'main' or 'release/*' branches"
18
+ exit 1
19
+ fi
18
20
21
+ check-updates :
19
22
runs-on : ubuntu-latest
23
+ outputs :
24
+ should_run : ${{ steps.check.outputs.should_run }}
20
25
steps :
21
26
- name : Checkout
22
27
uses : actions/checkout@v5
23
28
with :
24
- ref : main
29
+ fetch-depth : 50
30
+
31
+ - name : Check if SNAPSHOT publish is applicable
32
+ id : check
33
+ run : |
34
+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
35
+ echo "::notice::publish will always execute on manual trigger"
36
+ echo "should_run=true" >> $GITHUB_OUTPUT
37
+ else
38
+ if git log --since="7 days ago" --oneline | grep .; then
39
+ echo "::notice::commits found within last 7 days window, publish will execute"
40
+ echo "should_run=true" >> $GITHUB_OUTPUT
41
+ else
42
+ echo "::notice::no commits found within last 7 days window, publish will abort"
43
+ echo "should_run=false" >> $GITHUB_OUTPUT
44
+ fi
45
+ fi
46
+
47
+ publish-snapshot :
48
+ needs : [ check-branch, check-updates ]
49
+ if : needs.check-updates.outputs.should_run == 'true'
50
+ runs-on : ubuntu-latest
51
+ steps :
52
+ - name : Checkout
53
+ uses : actions/checkout@v5
25
54
26
55
- name : Set up JDK 17
27
56
uses : actions/setup-java@v5
0 commit comments