mirror of
https://github.com/tschoffelen/gha.git
synced 2024-08-18 00:30:27 +03:00
Making improvements for cross-platform support.
This commit is contained in:
parent
4c901016a2
commit
193eca70db
14
lib/utils.js
14
lib/utils.js
@ -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
18
package-lock.json
generated
@ -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",
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user