diff --git a/index.js b/index.js deleted file mode 100644 index de39c3b..0000000 --- a/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import core from '@actions/core'; -import github from '@actions/github'; - -try { - // `who-to-greet` input defined in action metadata file - const nameToGreet = core.getInput('who-to-greet'); - console.log(`Hello ${nameToGreet}!`); - const time = (new Date()).toTimeString(); - core.setOutput("time", time); - // Get the JSON webhook payload for the event that triggered the workflow - const payload = JSON.stringify(github.context.payload, undefined, 2) - console.log(`The event payload: ${payload}`); -} catch (error) { - core.setFailed(error.message); -} diff --git a/package.json b/package.json index 27293f5..341b077 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,10 @@ "name": "python-packs", "version": "1.0.0", "description": "", - "main": "index.js", + "type": "module", + "main": "src/index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "dev": "node src/index.js" }, "keywords": [], "author": "", diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..334f128 --- /dev/null +++ b/src/index.js @@ -0,0 +1,28 @@ +import core from '@actions/core'; +import github from '@actions/github'; +import execSync from 'child_process'; + +function ensure_pip() { + // call "python3 -m ensurepip" + execSync('python3 -m ensurepip'); +} + +function greeting() { + try { + // `who-to-greet` input defined in action metadata file + const nameToGreet = core.getInput('who-to-greet'); + console.log(`Hello ${nameToGreet}!`); + const time = (new Date()).toTimeString(); + core.setOutput("time", time); + // Get the JSON webhook payload for the event that triggered the workflow + const payload = JSON.stringify(github.context.payload, undefined, 2) + console.log(`The event payload: ${payload}`); + } catch (error) { + core.setFailed(error.message); + } +} + +function main() { + greeting(); + ensure_pip(); +}