mirror of
https://github.com/tschoffelen/gha.git
synced 2024-09-11 21:37:16 +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 glob = require('glob')
|
||||||
const chalk = require('chalk')
|
const chalk = require('chalk')
|
||||||
const {exec} = require('shelljs')
|
const {exec} = require('shelljs')
|
||||||
|
const tmp = require('temp-dir')
|
||||||
|
const mkdirp = require('mkdirp')
|
||||||
|
|
||||||
const cleanupHcl = (hcl) => {
|
const cleanupHcl = (hcl) => {
|
||||||
const objects = {}
|
const objects = {}
|
||||||
@ -68,14 +70,16 @@ const resolveRunner = (uses, verbose) => {
|
|||||||
subdir = subdir || ''
|
subdir = subdir || ''
|
||||||
|
|
||||||
let baseName = `${user}-${repo}-${subdir.replace(/\//g, '-')}`.replace(/-+$/, '')
|
let baseName = `${user}-${repo}-${subdir.replace(/\//g, '-')}`.replace(/-+$/, '')
|
||||||
let cacheFile = `/tmp/gha.${baseName}-${version}`
|
let cacheFile = path.join(tmp, `gha.${baseName}-${version}`)
|
||||||
let dockerFile = `${cacheFile}/*/${subdir}/Dockerfile`
|
let dockerFile = path.join(cacheFile, '*', subdir, 'Dockerfile')
|
||||||
|
|
||||||
if (!glob.sync(dockerFile).length) {
|
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(`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(`tar xf ${cacheFile}.tgz -C ${cacheFile}/`)
|
||||||
exec(`rm ${cacheFile}.tgz`)
|
try {
|
||||||
|
fs.unlinkSync(`${cacheFile}.tgz`)
|
||||||
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glob.sync(dockerFile).length) {
|
if (!glob.sync(dockerFile).length) {
|
||||||
@ -164,7 +168,7 @@ const runAction = (actionTitle, actions, event, verbose) => {
|
|||||||
`--rm`,
|
`--rm`,
|
||||||
`-t`,
|
`-t`,
|
||||||
`-v \`pwd\`:/github/workspace`,
|
`-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`,
|
`-v ${assetPath}:/github/workflow/event.json:ro`,
|
||||||
`-w /github/workspace`,
|
`-w /github/workspace`,
|
||||||
args.join(' '),
|
args.join(' '),
|
||||||
|
18
package-lock.json
generated
18
package-lock.json
generated
@ -119,6 +119,19 @@
|
|||||||
"brace-expansion": "^1.1.7"
|
"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": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
@ -171,6 +184,11 @@
|
|||||||
"has-flag": "^3.0.0"
|
"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": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
"commander": "^2.19.0",
|
"commander": "^2.19.0",
|
||||||
"glob": "^7.1.3",
|
"glob": "^7.1.3",
|
||||||
"hcl": "^0.1.0",
|
"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