mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-21 13:49:06 +08:00
use GITHUB_WORKSPACE as default download dir
This commit is contained in:
parent
dd26bb1149
commit
671bf1ebd5
@ -9,6 +9,7 @@ import {
|
|||||||
DownloadArtifactResponse
|
DownloadArtifactResponse
|
||||||
} from '../shared/interfaces'
|
} from '../shared/interfaces'
|
||||||
import {getUserAgentString} from '../shared/user-agent'
|
import {getUserAgentString} from '../shared/user-agent'
|
||||||
|
import { getGitHubWorkspaceDir } from '../shared/config'
|
||||||
|
|
||||||
const scrubQueryParameters = (url: string): string => {
|
const scrubQueryParameters = (url: string): string => {
|
||||||
const parsed = new URL(url)
|
const parsed = new URL(url)
|
||||||
@ -54,7 +55,7 @@ export async function downloadArtifact(
|
|||||||
token: string,
|
token: string,
|
||||||
options?: DownloadArtifactOptions
|
options?: DownloadArtifactOptions
|
||||||
): Promise<DownloadArtifactResponse> {
|
): Promise<DownloadArtifactResponse> {
|
||||||
let downloadPath = options?.path || process.cwd() // TODO: make this align with GITHUB_WORKSPACE
|
let downloadPath = options?.path || getGitHubWorkspaceDir()
|
||||||
if (options?.createArtifactFolder) {
|
if (options?.createArtifactFolder) {
|
||||||
downloadPath = path.join(downloadPath, 'my-artifact') // TODO: need to pass artifact name
|
downloadPath = path.join(downloadPath, 'my-artifact') // TODO: need to pass artifact name
|
||||||
}
|
}
|
||||||
|
@ -26,3 +26,11 @@ export function isGhes(): boolean {
|
|||||||
)
|
)
|
||||||
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
|
return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getGitHubWorkspaceDir(): string {
|
||||||
|
const ghWorkspaceDir = process.env['GITHUB_WORKSPACE']
|
||||||
|
if (!ghWorkspaceDir) {
|
||||||
|
throw new Error('Unable to get the GITHUB_WORKSPACE env variable')
|
||||||
|
}
|
||||||
|
return ghWorkspaceDir
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user