Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix artifact upload #215

Merged
merged 2 commits into from Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 16 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

31 changes: 19 additions & 12 deletions src/installer.ts
@@ -1,5 +1,6 @@
import * as artifact from '@actions/artifact'
import * as core from '@actions/core'
import * as glob from '@actions/glob'
import {OSType, getOs} from './platform'
import {SemVer} from 'semver'
import {exec} from '@actions/exec'
Expand Down Expand Up @@ -64,25 +65,31 @@ export async function install(
const exitCode = await exec(command, installArgs, execOptions)
core.debug(`Installer exit code: ${exitCode}`)
} catch (error) {
core.debug(`Error during installation: ${error}`)
core.warning(`Error during installation: ${error}`)
throw error
} finally {
// Always upload installation log regardless of error
if ((await getOs()) === OSType.linux) {
const artifactClient = artifact.create()
const artifactName = 'install-log'
const files = ['/var/log/cuda-installer.log']
const rootDirectory = '/var/log'
const artifactOptions = {
continueOnError: true
const patterns = ['/var/log/cuda-installer.log']
const globber = await glob.create(patterns.join('\n'))
const files = await globber.glob()
if (files.length > 0) {
const rootDirectory = '/var/log'
const artifactOptions = {
continueOnError: true
}
const uploadResult = await artifactClient.uploadArtifact(
artifactName,
files,
rootDirectory,
artifactOptions
)
core.debug(`Upload result: ${uploadResult}`)
} else {
core.debug(`No log file to upload`)
}
const uploadResult = await artifactClient.uploadArtifact(
artifactName,
files,
rootDirectory,
artifactOptions
)
core.debug(`Upload result: ${uploadResult}`)
}
}
}