Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe6f73865e | |||
| 9e67f6e707 | |||
| bf8696f8ed | |||
| b802b32103 | |||
| 2f31e7278d | |||
| 9a01ddca95 |
@@ -62,9 +62,9 @@ jobs:
|
|||||||
# We're using node -e to call the functions directly available in the @actions/artifact package
|
# We're using node -e to call the functions directly available in the @actions/artifact package
|
||||||
- name: Upload artifacts using uploadArtifact()
|
- name: Upload artifacts using uploadArtifact()
|
||||||
run: |
|
run: |
|
||||||
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-1',['artifact-path/world.txt'], process.argv[1]))" "${{ github.workspace }}"
|
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-1',['artifact-path/world.txt'], '${{ github.workspace }}'))"
|
||||||
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-2',['artifact-path/gzip.txt'], process.argv[1]))" "${{ github.workspace }}"
|
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-2',['artifact-path/gzip.txt'], '${{ github.workspace }}'))"
|
||||||
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-3',['artifact-path/empty.txt'], process.argv[1]))" "${{ github.workspace }}"
|
node -e "Promise.resolve(require('./packages/artifact/lib/artifact-client').create().uploadArtifact('my-artifact-3',['artifact-path/empty.txt'], '${{ github.workspace }}'))"
|
||||||
|
|
||||||
- name: Download artifacts using downloadArtifact()
|
- name: Download artifacts using downloadArtifact()
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import {debug} from '@actions/core'
|
import {debug} from '@actions/core'
|
||||||
import {join, normalize, resolve} from 'path'
|
import {join, normalize, resolve, toNamespacedPath} from 'path'
|
||||||
import {checkArtifactFilePath} from './path-and-artifact-name-validation'
|
import {checkArtifactFilePath} from './path-and-artifact-name-validation'
|
||||||
|
|
||||||
export interface UploadSpecification {
|
export interface UploadSpecification {
|
||||||
@@ -22,17 +22,19 @@ export function getUploadSpecification(
|
|||||||
// artifact name was checked earlier on, no need to check again
|
// artifact name was checked earlier on, no need to check again
|
||||||
const specifications: UploadSpecification[] = []
|
const specifications: UploadSpecification[] = []
|
||||||
|
|
||||||
if (!fs.existsSync(rootDirectory)) {
|
const rootPath = join(rootDirectory)
|
||||||
throw new Error(`Provided rootDirectory ${rootDirectory} does not exist`)
|
|
||||||
|
if (!fs.existsSync(rootPath)) {
|
||||||
|
throw new Error(`Provided rootDirectory ${rootPath} does not exist`)
|
||||||
}
|
}
|
||||||
if (!fs.lstatSync(rootDirectory).isDirectory()) {
|
if (!fs.lstatSync(rootPath).isDirectory()) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Provided rootDirectory ${rootDirectory} is not a valid directory`
|
`Provided rootDirectory ${rootPath} is not a valid directory`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Normalize and resolve, this allows for either absolute or relative paths to be used
|
// Normalize and resolve, this allows for either absolute or relative paths to be used
|
||||||
rootDirectory = normalize(rootDirectory)
|
rootDirectory = normalize(rootPath)
|
||||||
rootDirectory = resolve(rootDirectory)
|
rootDirectory = resolve(rootPath)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Example to demonstrate behavior
|
Example to demonstrate behavior
|
||||||
@@ -61,14 +63,14 @@ export function getUploadSpecification(
|
|||||||
// Normalize and resolve, this allows for either absolute or relative paths to be used
|
// Normalize and resolve, this allows for either absolute or relative paths to be used
|
||||||
file = normalize(file)
|
file = normalize(file)
|
||||||
file = resolve(file)
|
file = resolve(file)
|
||||||
if (!file.startsWith(rootDirectory)) {
|
if (!file.startsWith(rootPath)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`The rootDirectory: ${rootDirectory} is not a parent directory of the file: ${file}`
|
`The rootDirectory: ${rootPath} is not a parent directory of the file: ${file}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for forbidden characters in file paths that will be rejected during upload
|
// Check for forbidden characters in file paths that will be rejected during upload
|
||||||
const uploadPath = file.replace(rootDirectory, '')
|
const uploadPath = file.replace(rootPath, '')
|
||||||
checkArtifactFilePath(uploadPath)
|
checkArtifactFilePath(uploadPath)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user