use module

This commit is contained in:
shenjack 2023-12-10 11:52:28 +08:00
parent 17b23b7e6b
commit 85c2e8d21d
Signed by: shenjack
GPG Key ID: 7B1134A979775551
3 changed files with 31 additions and 17 deletions

View File

@ -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);
}

View File

@ -2,9 +2,10 @@
"name": "python-packs", "name": "python-packs",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "type": "module",
"main": "src/index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "dev": "node src/index.js"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",

28
src/index.js Normal file
View File

@ -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();
}