-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
52 lines (44 loc) · 1.88 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
# Set matrix ouput in file to be uploaded as artifacts, because github action does not handle job outputs for matrix
# Workaround for https://github.com/orgs/community/discussions/26639
name: "Set matrix ouput"
description: "Set matrix ouput in file to be uploaded as artifacts, because GitHub action does not handle job outputs for matrix"
author: Hoverkraft
branding:
icon: upload-cloud
color: gray-dark
inputs:
value:
description: "The matrix output to set."
required: true
artifact-name:
description: "The name of the artifact to upload."
required: true
outputs:
artifact-name:
description: "The real unique name of the uploaded artifact."
value: ${{ steps.prepare-upload.outputs.artifact-name }}
runs:
using: "composite"
steps:
- id: prepare-upload
uses: actions/github-script@v7
with:
script: |
const { join } = require('path');
const { existsSync, writeFileSync } = require('fs');
const { randomUUID } = require('crypto');
const artifactName = `${{ github.run_id }}-${{ github.run_number }}-${{ inputs.artifact-name }}`;
core.setOutput("artifact-name", artifactName);
const uniquid = randomUUID();
const timestamp = Date.now();
const artifactUniqueName = `${artifactName}-${timestamp}-${uniquid}`;
core.setOutput("artifact-unique-name", artifactUniqueName);
const artifactDirPath = join("/tmp",artifactUniqueName);
await io.mkdirP(artifactDirPath);
const artifactPath = join(artifactDirPath, `${artifactUniqueName}.json`);
core.setOutput("artifact-path", artifactPath);
writeFileSync(artifactPath, `${{ inputs.value }}`);
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.prepare-upload.outputs.artifact-unique-name }}
path: ${{ steps.prepare-upload.outputs.artifact-path }}