-
-
Notifications
You must be signed in to change notification settings - Fork 5
116 lines (109 loc) · 3.57 KB
/
promote-artifacts.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
name: Promote artifacts
on:
workflow_call:
inputs:
groups:
description: "Maven groups CSV. If only one group is specified, it will be used for all artifacts."
required: true
type: string
artifacts:
description: "Maven artifacts CSV"
required: true
type: string
version:
description: "Maven version"
required: true
type: string
type:
description: "Promotion type"
required: false
type: string
default: "latest"
secrets:
PROMOTE_ARTIFACT_WEBHOOK:
required: true
PROMOTE_ARTIFACT_USERNAME:
required: true
PROMOTE_ARTIFACT_PASSWORD:
required: true
workflow_dispatch:
inputs:
groups:
description: "Maven groups CSV. If only one group is specified, it will be used for all artifacts."
required: true
type: string
artifacts:
description: "Maven artifacts CSV"
required: true
type: string
version:
description: "Maven version"
required: true
type: string
type:
description: "Promotion type"
required: false
type: choice
default: "latest"
options:
- "latest"
- "recommended"
jobs:
promote-artifact:
name: Promote artifact
runs-on: ubuntu-latest
steps:
- name: Create JSONs
id: create-jsons
uses: actions/github-script@v7
env:
groups: ${{ inputs.groups }}
artifacts: ${{ inputs.artifacts }}
version: ${{ inputs.version }}
type: ${{ inputs.type }}
with:
result-encoding: string
# language=js
script: |
'use strict';
const { version, type } = process.env
let { groups, artifacts } = process.env
groups = groups.split(',')
artifacts = artifacts.split(',')
/** @type string[] */
const jsons = []
for (let i = 0; i < artifacts.length; i++) {
jsons.push(JSON.stringify({
group: `${groups[i] ?? groups[0]}`,
artifact: `${artifacts[i]}`,
version: `${version}`,
type: `${type}`
}))
}
return jsons.join('UwU')
- name: Notify webhook
uses: actions/github-script@v7
env:
jsons: ${{ steps.create-jsons.outputs.result }}
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}
PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }}
PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }}
with:
# language=js
script: |
'use strict';
/** @type {{exec: (command: string, args?: string[]) => Promise<number>}} */
const actionsExec = require('@actions/exec');
const { jsons, PROMOTE_ARTIFACT_WEBHOOK, PROMOTE_ARTIFACT_USERNAME, PROMOTE_ARTIFACT_PASSWORD } = process.env
/** @type string[] */
const jsonsList = jsons.split('UwU')
for (const json of jsonsList) {
await actionsExec.exec('curl', [
'--tlsv1.3', '--compressed', '-sS', '-m', '10',
'-u', `${PROMOTE_ARTIFACT_USERNAME}:${PROMOTE_ARTIFACT_PASSWORD}`,
'-H', 'Content-Type: application/json',
'--request', 'POST',
'-d', `${json}`,
`${PROMOTE_ARTIFACT_WEBHOOK}`
])
}