Making improvements for cross-platform support.

This commit is contained in:
Thomas Schoffelen 2019-02-22 11:38:37 +00:00
parent 4c901016a2
commit 193eca70db
No known key found for this signature in database
GPG Key ID: 03F5C979F442A38D
3 changed files with 30 additions and 6 deletions

View File

@ -3,6 +3,8 @@ const path = require('path')
const glob = require('glob')
const chalk = require('chalk')
const {exec} = require('shelljs')
const tmp = require('temp-dir')
const mkdirp = require('mkdirp')
const cleanupHcl = (hcl) => {
const objects = {}
@ -68,14 +70,16 @@ const resolveRunner = (uses, verbose) => {
subdir = subdir || ''
let baseName = `${user}-${repo}-${subdir.replace(/\//g, '-')}`.replace(/-+$/, '')
let cacheFile = `/tmp/gha.${baseName}-${version}`
let dockerFile = `${cacheFile}/*/${subdir}/Dockerfile`
let cacheFile = path.join(tmp, `gha.${baseName}-${version}`)
let dockerFile = path.join(cacheFile, '*', subdir, 'Dockerfile')
if (!glob.sync(dockerFile).length) {
exec(`curl -o ${cacheFile}.tgz --fail --silent --show-error --location https://api.github.com/repos/${user}/${repo}/tarball/${version}`)
exec(`mkdir -p ${cacheFile}`)
mkdirp.sync(cacheFile)
exec(`tar xf ${cacheFile}.tgz -C ${cacheFile}/`)
exec(`rm ${cacheFile}.tgz`)
try {
fs.unlinkSync(`${cacheFile}.tgz`)
} catch (e) {}
}
if (!glob.sync(dockerFile).length) {
@ -164,7 +168,7 @@ const runAction = (actionTitle, actions, event, verbose) => {
`--rm`,
`-t`,
`-v \`pwd\`:/github/workspace`,
`-v /tmp/gh-home:/github/home`,
`-v ${path.join(tmp, 'gh-home')}:/github/home`,
`-v ${assetPath}:/github/workflow/event.json:ro`,
`-w /github/workspace`,
args.join(' '),

18
package-lock.json generated
View File

@ -119,6 +119,19 @@
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": {
"minimist": "0.0.8"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@ -171,6 +184,11 @@
"has-flag": "^3.0.0"
}
},
"temp-dir": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-1.0.0.tgz",
"integrity": "sha1-CnwOom06Oa+n4OvqnB/AvE2qAR0="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -34,6 +34,8 @@
"commander": "^2.19.0",
"glob": "^7.1.3",
"hcl": "^0.1.0",
"shelljs": "^0.8.3"
"mkdirp": "^0.5.1",
"shelljs": "^0.8.3",
"temp-dir": "^1.0.0"
}
}