-
Notifications
You must be signed in to change notification settings - Fork 108
160 lines (143 loc) · 5.32 KB
/
Copy pathparser.yml
File metadata and controls
160 lines (143 loc) · 5.32 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
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
name: parser
on:
pull_request:
types: [ opened, edited, synchronize, reopened ]
workflow_dispatch:
inputs:
pull_request_repo:
description: 'Repository to check out (optional)'
required: false
type: string
pull_request_ref:
description: 'Branch or commit to test (optional)'
required: false
type: string
jdk17:
description: 'JDK17'
required: true
type: boolean
default: false
jdk21:
description: 'JDK21'
required: true
type: boolean
default: false
jdk25:
description: 'JDK25'
required: true
type: boolean
default: true
WILDFLY_RELEASE_VERSION:
description: 'WILDFLY_RELEASE_VERSION: the version of WildFly to checkout.'
required: false
type: string
workflow_call:
inputs:
jdk_versions:
description: 'JDK versions'
required: true
type: string
default: '["25"]'
pull_request_repo:
description: 'Repository to check out (optional)'
required: false
type: string
pull_request_ref:
description: 'Branch or commit to test (optional)'
required: false
type: string
environment_variables:
description: 'The environment variables to use in quickstart.sh'
required: false
type: string
default: '{}'
permissions:
actions: write
pull-requests: read
contents: read
jobs:
parser:
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
jdk_versions: ${{ steps.parse.outputs.jdk_versions || steps.set-axes-inputs.outputs.jdk_versions || '["25"]' }}
environment_variables: ${{ steps.parse.outputs.environment_variables || steps.set-axes-inputs.outputs.environment_variables || '{}' }}
pr_number: ${{ steps.set-pr-data.outputs.pr_number }}
pr_ref: ${{ steps.set-pr-data.outputs.pr_ref }}
pr_repo: ${{ steps.set-pr-data.outputs.pr_repo }}
steps:
- name: Extract PR metadata
id: set-pr-data
if: ${{ github.event_name == 'pull_request' }}
run: |
echo 'pr_number=${{ github.event.pull_request.number }}' >> $GITHUB_OUTPUT
echo 'pr_ref=${{ github.event.pull_request.head.ref }}' >> $GITHUB_OUTPUT
echo 'pr_repo=${{ github.event.pull_request.head.repo.full_name }}' >> $GITHUB_OUTPUT
- name: Parse PR description
id: parse
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v9
with:
script: |
const pr = context.payload.pull_request;
const prBody = pr.body || '';
// Matches JDK17, JDK21, etc.
const jdkRegex = /\bJDK(17|21|25)\b/gi;
const matches = [...prBody.matchAll(jdkRegex)];
let jdk_versions = matches.map(m => parseInt(m[1], 10));
if (jdk_versions.length === 0) {
jdk_versions = [25];
core.info(`Using JDK25.`);
} else {
core.info(`JDKs detected in PR body: ${jdk_versions}`);
}
core.setOutput('jdk_versions', JSON.stringify(jdk_versions));
const possibleEnvVars = [
'WILDFLY_RELEASE_VERSION',
'NARAYANA_REPO',
'NARAYANA_BRANCH',
'NY_BRANCH',
'LRA_REPO',
'LRA_BRANCH'
];
const extractedEnvVars = {};
for (const varName of possibleEnvVars) {
// Matches "VAR=value" stopping at the first whitespace
const regex = new RegExp(`\\b${varName}=([^\\s]+)`);
const match = prBody.match(regex);
if (match) {
const value = match[1];
core.info(`Environment variables ${varName} detected: ${value}`);
extractedEnvVars[varName] = value;
}
}
core.setOutput('environment_variables', JSON.stringify(extractedEnvVars));
- name: Set axes according to triggering event
id: set-axes-inputs
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: actions/github-script@v9
with:
script: |
// Creates jdk_versions
const jdk_versions = [
${{ inputs.jdk17 }} && '17',
${{ inputs.jdk21 }} && '21',
${{ inputs.jdk25 }} && '25'
].filter(Boolean);
core.setOutput('jdk_versions', JSON.stringify(jdk_versions));
const extractedEnvVars = Object.fromEntries([
['WILDFLY_RELEASE_VERSION', '${{ inputs.WILDFLY_RELEASE_VERSION }}']
].filter(entry => entry[1] !== ''));
core.info(`Custom Envs: ${JSON.stringify(extractedEnvVars)}`);
core.setOutput('environment_variables', JSON.stringify(extractedEnvVars));
main:
needs: parser
uses: ./.github/workflows/main.yml
strategy:
matrix:
jdk_version: ${{ fromJSON(needs.parser.outputs.jdk_versions) }}
with:
jdk_version: ${{ matrix.jdk_version }}
pull_request_ref: ${{ needs.parser.outputs.pr_ref }}
pull_request_repo: ${{ needs.parser.outputs.pr_repo }}
environment_variables: ${{ needs.parser.outputs.environment_variables }}