mirror of
https://github.com/actions/upload-artifact.git
synced 2024-11-24 04:02:09 +00:00
fix: get path root from github.workspace
This commit is contained in:
parent
bbe4504729
commit
baac12d9f8
3 changed files with 28 additions and 5 deletions
2
.github/workflows/test-per-file.yml
vendored
2
.github/workflows/test-per-file.yml
vendored
|
@ -91,4 +91,4 @@ jobs:
|
||||||
path/**/dir-1/
|
path/**/dir-1/
|
||||||
!path/to/dir-3/*.gz
|
!path/to/dir-3/*.gz
|
||||||
artifact-per-file: true
|
artifact-per-file: true
|
||||||
artifact-name-rule: ${{ matrix.runs-on }}-${name}
|
artifact-name-rule: ${{ matrix.runs-on }}-${path}-${name}
|
||||||
|
|
15
dist/index.js
vendored
15
dist/index.js
vendored
|
@ -4781,6 +4781,15 @@ function run() {
|
||||||
}
|
}
|
||||||
const artifactsName = inputs['artifactsName'] || 'artifacts';
|
const artifactsName = inputs['artifactsName'] || 'artifacts';
|
||||||
const artifactPerFile = inputs['artifactPerFile'] || false;
|
const artifactPerFile = inputs['artifactPerFile'] || false;
|
||||||
|
// GitHub workspace
|
||||||
|
let githubWorkspacePath = process.env['GITHUB_WORKSPACE'] || undefined;
|
||||||
|
if (!githubWorkspacePath) {
|
||||||
|
core.warning('GITHUB_WORKSPACE not defined');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
githubWorkspacePath = path_1.default.resolve(githubWorkspacePath);
|
||||||
|
core.info(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`);
|
||||||
|
}
|
||||||
const rootDirectory = searchResult.rootDirectory;
|
const rootDirectory = searchResult.rootDirectory;
|
||||||
core.info('rootDirectory: ' + rootDirectory);
|
core.info('rootDirectory: ' + rootDirectory);
|
||||||
if (!artifactPerFile) {
|
if (!artifactPerFile) {
|
||||||
|
@ -4802,7 +4811,9 @@ function run() {
|
||||||
core.info('file: ' + file);
|
core.info('file: ' + file);
|
||||||
const pathObject = Object.assign({}, path_1.default.parse(file));
|
const pathObject = Object.assign({}, path_1.default.parse(file));
|
||||||
const pathBase = pathObject.base;
|
const pathBase = pathObject.base;
|
||||||
const pathRoot = path_1.default.parse(rootDirectory).dir;
|
const pathRoot = githubWorkspacePath
|
||||||
|
? githubWorkspacePath
|
||||||
|
: path_1.default.parse(rootDirectory).dir;
|
||||||
pathObject.root = pathRoot;
|
pathObject.root = pathRoot;
|
||||||
core.info('root: ' + pathRoot);
|
core.info('root: ' + pathRoot);
|
||||||
pathObject['path'] = file.slice(pathRoot.length, file.length - path_1.default.sep.length - pathBase.length);
|
pathObject['path'] = file.slice(pathRoot.length, file.length - path_1.default.sep.length - pathBase.length);
|
||||||
|
@ -4835,7 +4846,7 @@ function run() {
|
||||||
artifactName = `${i}__${artifactName}`;
|
artifactName = `${i}__${artifactName}`;
|
||||||
core.warning(`${oldArtifactName} => ${artifactName}`);
|
core.warning(`${oldArtifactName} => ${artifactName}`);
|
||||||
}
|
}
|
||||||
const uploadResponse = yield artifactClient.uploadArtifact(artifactName, [file], searchResult.rootDirectory, options);
|
const uploadResponse = yield artifactClient.uploadArtifact(artifactName, [file], rootDirectory, options);
|
||||||
if (uploadResponse.failedItems.length > 0) {
|
if (uploadResponse.failedItems.length > 0) {
|
||||||
FailedItems.push(artifactName);
|
FailedItems.push(artifactName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,16 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
const artifactsName = inputs['artifactsName'] || 'artifacts'
|
const artifactsName = inputs['artifactsName'] || 'artifacts'
|
||||||
const artifactPerFile = inputs['artifactPerFile'] || false
|
const artifactPerFile = inputs['artifactPerFile'] || false
|
||||||
|
|
||||||
|
// GitHub workspace
|
||||||
|
let githubWorkspacePath = process.env['GITHUB_WORKSPACE'] || undefined
|
||||||
|
if (!githubWorkspacePath) {
|
||||||
|
core.warning('GITHUB_WORKSPACE not defined')
|
||||||
|
} else {
|
||||||
|
githubWorkspacePath = path.resolve(githubWorkspacePath)
|
||||||
|
core.info(`GITHUB_WORKSPACE = '${githubWorkspacePath}'`)
|
||||||
|
}
|
||||||
|
|
||||||
const rootDirectory = searchResult.rootDirectory
|
const rootDirectory = searchResult.rootDirectory
|
||||||
core.info('rootDirectory: ' + rootDirectory)
|
core.info('rootDirectory: ' + rootDirectory)
|
||||||
|
|
||||||
|
@ -87,7 +97,9 @@ async function run(): Promise<void> {
|
||||||
|
|
||||||
const pathObject = Object.assign({}, path.parse(file))
|
const pathObject = Object.assign({}, path.parse(file))
|
||||||
const pathBase = pathObject.base
|
const pathBase = pathObject.base
|
||||||
const pathRoot = path.parse(rootDirectory).dir
|
const pathRoot = githubWorkspacePath
|
||||||
|
? githubWorkspacePath
|
||||||
|
: path.parse(rootDirectory).dir
|
||||||
pathObject.root = pathRoot
|
pathObject.root = pathRoot
|
||||||
core.info('root: ' + pathRoot)
|
core.info('root: ' + pathRoot)
|
||||||
|
|
||||||
|
@ -131,7 +143,7 @@ async function run(): Promise<void> {
|
||||||
const uploadResponse = await artifactClient.uploadArtifact(
|
const uploadResponse = await artifactClient.uploadArtifact(
|
||||||
artifactName,
|
artifactName,
|
||||||
[file],
|
[file],
|
||||||
searchResult.rootDirectory,
|
rootDirectory,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
if (uploadResponse.failedItems.length > 0) {
|
if (uploadResponse.failedItems.length > 0) {
|
||||||
|
|
Loading…
Reference in a new issue