-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaction.yml
40 lines (38 loc) · 1.29 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
name: GetRepoControlData
inputs:
repo:
required: true
type: string
outputs:
control_data:
description: "Control Data"
value: ${{ steps.setvars.outputs.control_data }}
runs:
using: "composite"
steps:
- id: setvars
uses: actions/github-script@v7
env:
REPO: "${{inputs.repo}}"
# Unfortunately, this has to be hardcoded because the
# action doesn't have access to the "vars" context.
CONTROLDATA_BASE: "https://raw.githubusercontent.com/asterisk/asterisk-ci-actions/main/.github/control"
CONTROLDATA_FILE: "${{inputs.repo}}.json"
with:
retries: 5
script: |
try {
// We need to strip off a potential leading organization
let repo = process.env.REPO.replace(/[^/]+\//,"");
let url = `${process.env.CONTROLDATA_BASE}/${repo}.json`;
const result = await github.request(url);
let jsonin = JSON.parse(result.data);
let jsonout = {};
for (const v of jsonin) {
jsonout[v.name] = v.value;
core.setOutput(v.name, v.value);
}
core.setOutput('control_data', jsonout);
} catch(err) {
core.setFailed(`Unable to retrieve or parse data for ${process.env.REPO}: }${err}`);
}