1515 type : string
1616 required : false
1717 default : ' '
18- scala :
19- type : string
20- required : false
21- default : " "
22- add-dimensions :
23- type : string
24- required : false
25- default : " {}"
26- include :
27- type : string
28- required : false
29- default : " []"
30- exclude :
31- type : string
32- required : false
33- default : " []"
3418 cmd :
3519 type : string
3620 required : true
6852 default : " "
6953
7054jobs :
71- prepare-matrix :
72- name : Prepare Matrix
73- if : >-
74- github.event.repository.fork == false ||
75- github.event_name != 'schedule' ||
76- (github.event_name == 'schedule' && github.event.repository.fork == true && inputs.run-scheduled-in-forks == true)
77- runs-on : ubuntu-24.04
78- outputs :
79- matrix : ${{ steps.prepare-matrix.outputs.matrix }}
80- steps :
81- - id : prepare-matrix
82- run : |
83- add_dimensions=$(echo -n '${{ inputs.add-dimensions }}' | sed 's/^.*{//;s/}.*$//') # Remove leading { and trailing }
84- # input java/scala | replace whitespaces/commas/quotes by newline | drop empty | quotation | join by comma
85- java=$(echo -n '${{inputs.java}}' | sed 's/[[:blank:],"]\+/\n/g' | awk NF | sed 's/^..*$/"&"/' | sed ':a; N; $!ba; s/\n/,/g')
86- scala=$(echo -n '${{inputs.scala}}' | sed 's/[[:blank:],"]\+/\n/g' | awk NF | sed 's/^..*$/"&"/' | sed ':a; N; $!ba; s/\n/,/g')
87- matrix="{"
88- matrix+="\"java\": [$java],"
89- [[ ! -z "$scala" ]] && matrix+="\"scala\": [$scala],"
90- matrix+="$(echo ${add_dimensions:+$add_dimensions,})"
91- matrix+="\"include\":$(echo -n '${{ inputs.include }}'),"
92- matrix+="\"exclude\":$(echo -n '${{ inputs.exclude }}')"
93- matrix+="}"
94- # Cleanup JSON (no unnecessary whitespaces, etc.)
95- matrix=$(jq -n -c "$matrix")
96- echo $matrix
97- echo "matrix=$matrix" >> $GITHUB_OUTPUT
9855 cmd :
99- name : ${{ toJSON(matrix) }}
10056 if : ${{ github.event.repository.fork == false || github.event_name != 'schedule' || (github.event_name == 'schedule' && github.event.repository.fork == true && inputs.run-scheduled-in-forks == true) }}
101- needs : prepare-matrix
10257 runs-on : ubuntu-24.04
103- strategy :
104- # WA: https://github.community/t/reusable-workflow-with-strategy-matrix/205676/6
105- matrix : ${{fromJson(needs.prepare-matrix.outputs.matrix)}}
10658 steps :
10759 - name : Block deprecated repos in /etc/hosts
10860 run : |
12981
13082 - name : Gradle Cache
13183 uses : burrunan/gradle-cache-action@v3
84+ if : ${{ hashFiles(format('{0}{1}{2}', inputs.gradle-build-root, inputs.gradle-build-root && '/' || '', 'gradle/wrapper/gradle-wrapper.properties')) != '' }}
13285 with :
13386 build-root-directory : ${{ inputs.gradle-build-root }}
13487 # Disable caching of ~/.gradle/caches/build-cache-*
@@ -140,21 +93,20 @@ jobs:
14093 uses : actions/cache@v4
14194 if : ${{ inputs.cache-key != '' && inputs.cache-path != '' }}
14295 with :
143- key : ${{ format(inputs.cache-key, matrix .java) }}
96+ key : ${{ format(inputs.cache-key, inputs .java) }}
14497 path : ${{ inputs.cache-path }}
14598
14699 - name : Install Adoptium Temurin OpenJDK
147100 uses : coursier/setup-action@v1
148101 with :
149- jvm : adoptium:${{ matrix .java }}
102+ jvm : adoptium:${{ inputs .java }}
150103 jvm-index : ${{ inputs.java-index }}
151104
152105 - name : Install sbt
153106 uses : sbt/setup-sbt@v1
154107
155108 - name : Print helpful configs and files and show environment
156109 run : |
157- echo "Matrix: ${{ toJSON(matrix) }}"
158110 echo "$ cat /etc/sbt/jvmopts"
159111 cat /etc/sbt/jvmopts || true
160112 echo ""
@@ -168,10 +120,6 @@ jobs:
168120 echo "ls -alFhR ~/.cache/coursier | grep play | grep jar"
169121 ls -alFhR ~/.cache/coursier | grep play | grep jar || true
170122
171- - name : Convert matrix elements to environment variables
172- run : |
173- jq -n -r '$in | to_entries|map("MATRIX_\(.key|ascii_upcase)=\(.value|tostring)")|.[]' --argjson in '${{ toJSON(matrix) }}' >> $GITHUB_ENV
174-
175123 - name : Run command
176124 run : ${{ inputs.cmd }}
177125 env :
0 commit comments