Skip to content

Commit

Permalink
use os to get user
Browse files Browse the repository at this point in the history
  • Loading branch information
qthequartermasterman authored and Jimver committed Nov 15, 2024
1 parent 00eb44e commit 7628297
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dist/index.js

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

4 changes: 3 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as glob from '@actions/glob'
import {OSType, getOs, getRelease} from './platform'
import {SemVer} from 'semver'
import {exec} from '@actions/exec'
import * as os from 'os'

export async function install(
executablePath: string,
Expand Down Expand Up @@ -78,12 +79,13 @@ export async function install(
const patterns = ['/var/log/cuda-installer.log']
const globber = await glob.create(patterns.join('\n'))
const files = await globber.glob()
const username = os.userInfo().username
if (files.length > 0) {
// If any of the files is not readable without root permissions, the upload will fail, so we need to
// fix the permissions first
for (const file of files) {
await exec(`sudo chmod 644 ${file}`)
await exec(`sudo chown \`whoami\` ${file}`)
await exec(`sudo chown ${username} ${file}`)
}
const rootDirectory = '/var/log'
const uploadResult = await artifact.uploadArtifact(
Expand Down

0 comments on commit 7628297

Please sign in to comment.