This commit is contained in:
Konrad Pabjan 2020-02-20 15:48:03 -05:00
parent 18f0f591fb
commit 6ced765a9f
12 changed files with 4792 additions and 4 deletions

3
.eslintignore Normal file
View file

@ -0,0 +1,3 @@
node_modules/
lib/
dist/

16
.eslintrc.json Normal file
View file

@ -0,0 +1,16 @@
{
"env": { "node": true, "jest": true },
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": 9, "sourceType": "module" },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
],
"plugins": ["@typescript-eslint"]
}

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
# Ignore node_modules, ncc is used to compile nodejs modules into a single file in the releases branch
node_modules/
# Ignore js files that are transpiled from ts files in src/
lib/

3
.prettierignore Normal file
View file

@ -0,0 +1,3 @@
dist/
lib/
node_modules/

11
.prettierrc.json Normal file
View file

@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}

View file

@ -4,9 +4,10 @@ author: 'GitHub'
inputs:
name:
description: 'Artifact name'
required: true
required: false
path:
description: 'Destination path'
description: 'Destination path'
required: false
runs:
# Plugins live on the runner and are only available to a certain set of first party actions.
plugin: 'download'
using: 'node12'
main: 'dist/index.js'

2304
dist/index.js vendored Normal file

File diff suppressed because it is too large Load diff

2362
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

41
package.json Normal file
View file

@ -0,0 +1,41 @@
{
"name": "download-artifact",
"version": "2.0.0",
"description": "Download a build artifact that was previously uploaded in the workflow by the upload-artifact action",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"release": "ncc build src/download-artifact.ts && git add -f dist/",
"check-all": "concurrently \"npm:format-check\" \"npm:lint\" \"npm:build\"",
"format": "prettier --write **/*.ts",
"format-check": "prettier --check **/*.ts",
"lint": "eslint **/*.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/download-artifact.git"
},
"keywords": [
"Actions",
"GitHub",
"Artifacts",
"Download"
],
"author": "GitHub",
"license": "MIT",
"bugs": {
"url": "https://github.com/actions/download-artifact/issues"
},
"homepage": "https://github.com/actions/download-artifact#readme",
"dependencies": {
"@actions/artifact": "^0.1.0",
"@actions/core": "^1.2.2",
"@typescript-eslint/parser": "^2.20.0",
"@zeit/ncc": "^0.21.1",
"concurrently": "^5.1.0",
"eslint": "^6.8.0",
"eslint-plugin-github": "^3.4.1",
"prettier": "^1.19.1",
"typescript": "^3.7.5"
}
}

4
src/constants.ts Normal file
View file

@ -0,0 +1,4 @@
export enum Inputs {
Name = 'name',
Path = 'path'
}

25
src/download-artifact.ts Normal file
View file

@ -0,0 +1,25 @@
import * as core from '@actions/core'
import * as artifact from '@actions/artifact'
import {Inputs} from './constants'
async function run(): Promise<void> {
try {
const name = core.getInput(Inputs.Name, {required: false})
const path = core.getInput(Inputs.Path, {required: false})
const artifactClient = artifact.create()
if (!name) {
// download all artifacts
await artifactClient.downloadAllArtifacts(path)
} else {
// download a single artifact
await artifactClient.downloadArtifact(name, path, {
createArtifactFolder: false
})
}
} catch (err) {
core.setFailed(err.message)
}
}
run()

13
tsconfig.json Normal file
View file

@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"noImplicitAny": false,
"moduleResolution": "node",
"esModuleInterop": true
},
"exclude": ["node_modules", "**/*.test.ts"]
}