Skip to content

Commit 02e5532

Browse files
authored
Update Java CI Workflow to latest (#13253)
1 parent 9aac1e7 commit 02e5532

File tree

1 file changed

+48
-47
lines changed

1 file changed

+48
-47
lines changed

.github/workflows/gradle.yml

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,77 +2,78 @@ name: Java CI
22
on:
33
push:
44
branches:
5-
- master
65
- '[4-9]+.[0-9]+.x'
76
- '[3-9]+.[3-9]+.x'
87
pull_request:
98
branches:
10-
- master
119
- '[4-9]+.[0-9]+.x'
1210
- '[3-9]+.[3-9]+.x'
1311
workflow_dispatch:
12+
permissions:
13+
contents: read # to fetch code (actions/checkout)
1414
jobs:
1515
build:
16+
permissions:
17+
contents: read # to fetch code (actions/checkout)
1618
runs-on: ubuntu-latest
17-
strategy:
18-
matrix:
19-
java: ['8', '11']
20-
env:
21-
WORKSPACE: ${{ github.workspace }}
22-
GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8
2319
steps:
24-
- uses: actions/checkout@v2
25-
- uses: actions/cache@v2
26-
with:
27-
path: ~/.gradle/caches
28-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
29-
restore-keys: |
30-
${{ runner.os }}-gradle-
20+
- uses: actions/checkout@v3
3121
- name: Set up JDK
32-
uses: actions/setup-java@v1
22+
uses: actions/setup-java@v3
23+
with:
24+
distribution: 'adopt'
25+
java-version: '8'
26+
- name: Run Build
27+
id: build
28+
uses: gradle/gradle-build-action@v2
29+
env:
30+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
31+
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
32+
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
3333
with:
34-
java-version: ${{ matrix.java }}
35-
- name: Optional setup step
36-
run: |
37-
[ -f ./setup.sh ] && ./setup.sh || true
38-
- name: Run Tests
39-
run: |
40-
(set -x; ./gradlew clean classes --no-daemon)
41-
(set -x; ./gradlew testClasses --no-daemon)
42-
./gradlew --stop
43-
(set -x; ./gradlew grails-test-suite-persistence:test grails-test-suite-uber:test grails-test-suite-web:test --no-daemon)
44-
./gradlew --stop
45-
(set -x; ./gradlew check -x grails-test-suite-persistence:test -x grails-test-suite-uber:test -x grails-test-suite-web:test --no-daemon)
46-
- name: Publish Test Report
47-
if: failure()
48-
uses: scacap/action-surefire-report@v1
34+
arguments: build
35+
publish:
36+
permissions:
37+
contents: read # to fetch code (actions/checkout)
38+
checks: write
39+
runs-on: ubuntu-latest
40+
if: github.event_name == 'push'
41+
needs: ['build']
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
4945
with:
50-
github_token: ${{ secrets.GITHUB_TOKEN }}
51-
report_paths: '**/build/test-results/test/TEST-*.xml'
52-
- name: Run Assemble
53-
if: success() && github.event_name == 'push' && matrix.java == '8'
54-
run: ./gradlew assemble
55-
- name: Publish to repo.grails.org
56-
if: success() && github.event_name == 'push' && matrix.java == '8'
46+
token: ${{ secrets.GH_TOKEN }}
47+
- name: Set up JDK
48+
uses: actions/setup-java@v3
49+
with:
50+
distribution: 'adopt'
51+
java-version: '8'
52+
- name: Publish to Artifactory (repo.grails.org)
53+
id: publish
54+
uses: gradle/gradle-build-action@v2
5755
env:
56+
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
57+
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
58+
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
5859
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
5960
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
60-
run: |
61-
./gradlew publish
61+
with:
62+
arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish
6263
- name: Extract branch name
63-
if: success() && github.event_name == 'push' && matrix.java == '8'
64+
if: success()
6465
id: extract_branch
65-
run: echo ::set-output name=value::${GITHUB_REF:11}
66+
run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
6667
- name: Create Snapshot Message for the Workflow Dispatch
67-
if: success() && github.event_name == 'push' && matrix.java == '8'
68+
if: success()
6869
id: dispatch_message
69-
run: echo ::set-output name=value::{\"message\":\"New Core Snapshot $(date) - $GITHUB_SHA\"}
70+
run: echo "value={\"message\":\"New Core Snapshot $(date) - $GITHUB_SHA\"}" >> $GITHUB_OUTPUT
7071
- name: Invoke the Java CI workflow in Grails Functional Tests
71-
if: success() && github.event_name == 'push' && matrix.java == '8'
72-
uses: benc-uk/workflow-dispatch@v1.1
72+
if: success()
73+
uses: benc-uk/workflow-dispatch@v1.2
7374
with:
7475
workflow: Java CI
7576
repo: grails/grails-functional-tests
7677
ref: ${{ steps.extract_branch.outputs.value }}
7778
token: ${{ secrets.GH_TOKEN }}
78-
inputs: ${{ steps.dispatch_message.outputs.value }}
79+
inputs: ${{ steps.dispatch_message.outputs.value }}

0 commit comments

Comments
 (0)