-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (160 loc) · 5.57 KB
/
standard-module.yml
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: GATE Standard Module CI
on:
workflow_call:
inputs:
java_version:
description: "Version of Java on which the workflow will run"
default: "8"
required: false
type: string
java_distribution:
description: "Java distribution to use"
default: "zulu"
required: false
type: string
test_report:
description: "Should we publish the test report as a workflow check?"
default: true
required: false
type: boolean
default_branch:
description: "Full refs/heads/XXX of the default branch of the calling repository, if not master"
default: "refs/heads/master"
required: false
type: string
deploy_site_to_pages:
description: "Should we deploy the maven site to GitHub Pages?"
default: true
required: false
type: boolean
fetch_depth:
description: "By default we do a shallow clone of the repository, to instead do a full clone set fetch_depth: '0'"
default: "1"
required: false
type: string
maven_version:
description: "Version of Maven to use for the build"
default: "3.8.8"
required: false
type: string
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
checks: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: ${{ inputs.fetch_depth }}
- name: Update submodules if necessary
run: |
if [ -f '.gitmodules' ]; then
git submodule update --init --recursive --depth=1
else
echo "Repository does not have submodules - nothing to do"
fi
- name: Setup Pages
if: inputs.deploy_site_to_pages
uses: actions/configure-pages@v5
continue-on-error: true
# This step may error out when run in a fork that doesn't have pages
# enabled - if this happens, run the rest but skip anything that
# involves publishing to pages. The last thing configure-pages does
# is set an environment variable GITHUB_PAGES=true which is visible
# to subsequent steps, so we can condition on that.
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java_version }}
distribution: ${{ inputs.java_distribution }}
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ inputs.maven_version }}
# Override http://repo.gate.ac.uk to use https:// instead
- name: Configure Maven settings
uses: whelk-io/maven-settings-xml-action@v22
with:
mirrors: >
[
{
"id": "gate.ac.uk-https",
"name": "GATE repo (secure)",
"mirrorOf": "gate.ac.uk",
"url": "https://repo.gate.ac.uk/content/groups/public/"
}
]
repositories: >
[
{
"id": "central",
"name": "Maven Central",
"url": "https://repo1.maven.org/maven2",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "false"
}
}
]
plugin_repositories: >
[
{
"id": "central",
"name": "Maven Central",
"url": "https://repo1.maven.org/maven2",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "false"
}
}
]
servers: >
[
{
"id": "gate.snapshots",
"username": "${{ secrets.GATE_REPO_USERNAME }}",
"password": "${{ secrets.GATE_REPO_PASSWORD }}"
}
]
- name: Build with Maven
run: mvn --batch-mode -e clean install
- name: Publish Test Report
if: (success() || failure()) && inputs.test_report
uses: EnricoMi/publish-unit-test-result-action@v2
with:
junit_files: "target/surefire-reports/*.xml"
- name: Build site
run: mvn --batch-mode -e -DskipTests site
- name: Upload artifact
if: github.ref == inputs.default_branch && env.GITHUB_PAGES == 'true'
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'target/site'
# Only do the deploy to repo.gate.ac.uk if we're in the main GateNLP
# repo, not a fork
- name: Deploy to repo.gate.ac.uk
if: github.ref == inputs.default_branch && github.repository_owner == 'GateNLP'
run: mvn --batch-mode -e -Dmaven.test.skip=true source:jar javadoc:jar deploy
# We want to avoid cacheing -SNAPSHOT dependencies from our local maven
# cache, to ensure that we always go out and check for them again at the
# next build in case they have changed.
- name: Delete snapshots from m2 repository
if: always()
run: |
find ~/.m2/repository -name \*-SNAPSHOT -type d -exec rm -rf {} \+ || :
- name: Deploy site to GitHub Pages
if: github.ref == inputs.default_branch && env.GITHUB_PAGES == 'true'
id: deployment
uses: actions/deploy-pages@v4