This repository was archived by the owner on Mar 20, 2025. It is now read-only.
forked from hmcts/java-logging
-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (111 loc) · 3.23 KB
/
ci.yml
File metadata and controls
120 lines (111 loc) · 3.23 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: CI
on:
release:
types: [released, prereleased]
push:
branches:
- main
pull_request:
permissions:
contents: read
packages: write
jobs:
test:
name: Test
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
cache: 'gradle'
- name: Compile and test
run: ./gradlew build --info
- name: Check coverage
run: ./gradlew jacocoTestCoverageVerification --info
- name: Archive code coverage results
uses: actions/upload-artifact@v3
if: failure()
with:
name: build-reports
path: '*/build/reports'
retention-days: 1
publish:
name: Publish
needs: [test]
if: github.event_name == 'release'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: corretto
java-version: 17
cache: 'gradle'
- name: Gradle publish
run: ./gradlew publish --info --no-daemon
env:
GH_USERNAME: ${{ secrets.GH_USERNAME }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
end:
name: End
needs: [test, publish]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
steps:
- name: Build summary
id: summary
env:
TEST: ${{ needs.test.result }}
PUBLISH: ${{ needs.publish.result }}
run: |
echo "success=$(if [[ "$TEST$PUBLISH" =~ ^(success|skipped)+$ ]]; then echo "true"; else echo "false"; fi)" >> $GITHUB_OUTPUT
- name: Notify slack fail
if: steps.summary.outputs.success != 'true' && env.SLACK_BOT_TOKEN != 0
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: dev
payload: |
{
"text": "${{github.repository}}: CI failed",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"emoji": true,
"text": ":x: ${{github.repository}}: CI failed"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Repository: <${{github.server_url}}/${{github.repository}}|${{github.repository}}>"
},
{
"type": "mrkdwn",
"text": "Triggered by: *${{github.triggering_actor}}*"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "See failed run: <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.run_id}}>"
}
}
]
}