Skip python setup when running in a container

This commit is contained in:
Peter Evans 2020-02-13 16:26:04 +09:00
parent bceebba814
commit 9d58699da5
4 changed files with 54 additions and 31 deletions

57
dist/index.js vendored
View file

@ -1001,34 +1001,24 @@ module.exports = require("os");
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
const { inspect } = __webpack_require__(669);
const isDocker = __webpack_require__(160);
const fs = __webpack_require__(747);
const core = __webpack_require__(470);
const exec = __webpack_require__(986);
const setupPython = __webpack_require__(139);
function fileExists(path) {
try {
return fs.statSync(path).isFile();
} catch (e) {
core.debug(`e: ${inspect(e)}`);
return false;
}
}
async function run() {
try {
// Allows ncc to find assets to be included in the distribution
const src = __webpack_require__.ab + "src";
core.debug(`src: ${src}`);
// Check if the platfrom is Alpine Linux
const alpineLinux = fileExists("/etc/alpine-release");
core.debug(`alpineLinux: ${alpineLinux}`);
// Skip Python setup if the platform is Alpine Linux
if (!alpineLinux)
if (isDocker()) {
core.info('Running inside a Docker container');
} else {
// Setup Python from the tool cache
setupPython("3.8.x", "x64");
}
// Install requirements
await exec.exec("pip", [
@ -1411,6 +1401,43 @@ if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
exports.debug = debug; // for test
/***/ }),
/***/ 160:
/***/ (function(module, __unusedexports, __webpack_require__) {
"use strict";
const fs = __webpack_require__(747);
let isDocker;
function hasDockerEnv() {
try {
fs.statSync('/.dockerenv');
return true;
} catch (_) {
return false;
}
}
function hasDockerCGroup() {
try {
return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
} catch (_) {
return false;
}
}
module.exports = () => {
if (isDocker === undefined) {
isDocker = hasDockerEnv() || hasDockerCGroup();
}
return isDocker;
};
/***/ }),
/***/ 211: