Skip to content

Commit bed9482

Browse files
committed
Allow uploading as artifact
1 parent daa593b commit bed9482

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ inputs:
2626
push:
2727
description: "Whether to push the new commit back to the repository. Default: true"
2828
required: false
29+
upload:
30+
description: "Whether to upload the new diagram as an artiface. Default: false"
31+
required: false
2932
runs:
3033
using: "node12"
3134
main: "index.js"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"test": "npm run test:jest --"
1010
},
1111
"dependencies": {
12+
"@actions/artifact": "^0.5.2",
1213
"@actions/core": "^1.4.0",
1314
"@actions/exec": "^1.1.0",
1415
"d3": "^7.0.0",

src/index.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { exec } from '@actions/exec'
22
import * as core from '@actions/core'
3+
import * as artifact from '@actions/artifact'
34
import React from 'react';
45
import ReactDOMServer from 'react-dom/server';
56
import fs from "fs"
@@ -84,6 +85,19 @@ const main = async () => {
8485
core.endGroup()
8586
}
8687

88+
const shouldUpload = getAsBoolean(core.getInput('upload'), false)
89+
if (shouldUpload) {
90+
core.startGroup('Upload diagram to artifacts')
91+
const client = artifact.create()
92+
const result = await client.uploadArtifact('Diagram', [outputFile], '.')
93+
if (result.failedItems.length > 0) {
94+
throw 'Artifact was not uploaded successfully.'
95+
} else {
96+
core.info(`Diagram uploaded under name ${result.artifactName}`)
97+
}
98+
core.endGroup()
99+
}
100+
87101
console.log("All set!")
88102
}
89103

0 commit comments

Comments
 (0)