-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
164 lines (153 loc) · 4.84 KB
/
action.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
name: 'Maven Builder'
description: 'Build and upload artifacts with maven'
inputs:
java_version:
description: Java runtime version
required: false
default: "8"
maven_version:
description: Maven version
required: false
default: "3.6.3"
additional_profiles:
description: "Additional mvn profiles to be executed in the mvn command (for example: 'jboss' or 'jboss,test')"
required: false
slack_channel_id:
description: Slack channel id for notifications
required: true
op_service_account_token:
description: 1Password service account token
required: true
enable_maven_dependency_check:
description: Enabling dependency check for maven when set to 'true'
required: false
default: "false"
outputs:
build_version:
description: "Build version from POM"
value: ${{ steps.pom-vars.outputs.build_version }}
artefact_id:
description: "Artifact id from POM"
value: ${{ steps.pom-vars.outputs.artefact_id }}
group_id:
description: "Group id from POM"
value: ${{ steps.pom-vars.outputs.group_id }}
runs:
using: "composite"
steps:
- name: Set up JDK ${{ inputs.java_version }}
uses: actions/[email protected]
with:
java-version: ${{ inputs.java_version }}
distribution: 'temurin'
# cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: ${{ inputs.maven_version }}
- name: Load Repo Secrets
id: op-load-repo-secrets
uses: 1password/[email protected]
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ inputs.op_service_account_token }}
NEXUSUSER: op://ajila_CICD/NEXUS/username
NEXUSPWD: op://ajila_CICD/NEXUS/password
- name: Prepare maven config file
uses: whelk-io/maven-settings-xml-action@v22
with:
repositories: >
[
{
"id": "central",
"url": "http://central",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "true"
}
}
]
plugin_repositories: >
[
{
"id": "central",
"url": "http://central",
"releases": {
"enabled": "true"
},
"snapshots": {
"enabled": "true"
}
}
]
servers: >
[
{
"id": "AjilaSnapshots",
"username": "${{ env.NEXUSUSER }}",
"password": "${{ env.NEXUSPWD }}"
},
{
"id": "AjilaReleases",
"username": "${{ env.NEXUSUSER }}",
"password": "${{ env.NEXUSPWD }}"
}
]
mirrors: >
[
{
"id": "nexus",
"mirrorOf": "*",
"url": "http://nexus.internal.ajila.com/repository/public/"
}
]
profiles: >
[
{
"id": "nexus"
}
]
active_profiles: >
[
"nexus"
]
plugin_groups: >
[
"com.google.cloud.tools"
]
output_file: .m2/settings.xml
- name: Set output variables
id: pom-vars
shell: bash
run: |
echo "build_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout -Pnexus --global-settings .m2/settings.xml)" >> $GITHUB_OUTPUT
echo "artefact_id=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout -Pnexus --global-settings .m2/settings.xml)" >> $GITHUB_OUTPUT
echo "group_id=$(mvn help:evaluate -Dexpression=project.groupId -q -DforceStdout -Pnexus --global-settings .m2/settings.xml)" >> $GITHUB_OUTPUT
- name: Build and upload to nexus
shell: bash
run: |
PROFILES="nexus"
if [[ -n "$ADDITIONAL_PROFILES" ]]; then
PROFILES="$PROFILES,$ADDITIONAL_PROFILES"
fi
mvn --global-settings .m2/settings.xml --batch-mode -P$PROFILES clean deploy
env:
ADDITIONAL_PROFILES: ${{ inputs.additional_profiles }}
- name: Upload Artifact to GitHub
uses: actions/[email protected]
with:
name: maven-artifacts
path: "**/target/*.zip"
- name: Maven Dependency Tree Dependency Submission
uses: advanced-security/[email protected]
with:
settings-file: .m2/settings.xml
if: inputs.enable_maven_dependency_check == 'true'
- name: Notify job status
if: always()
uses: ajilach/[email protected]
with:
op_service_account_token: ${{ inputs.op_service_account_token }}
slack_channel_id: ${{ inputs.slack_channel_id }}
job_status: ${{ job.status }}