【发布时间】:2019-11-22 19:04:36
【问题描述】:
我想在我的一些存储库之间共享 GitHub 操作,这些存储库现在在每个存储库中都包含一个发布 bash 脚本。
为了能够运行相同的脚本,我需要一个 Github Action 来执行此操作。
我对 javascript 知之甚少,无法重写简单的 hello world javascript 操作 (https://github.com/actions/hello-world-javascript-action/blob/master/index.js) 来运行 bash 脚本。
使用 javascript 作为操作的想法是首选,因为它的性能和提供对 GitHub webhook 有效负载的访问。
我第一次尝试提供基于 hello-world 动作的 javascript 动作:
const exec = require('@actions/exec');
const core = require('@actions/core');
const github = require('@actions/github');
try {
const filepath = core.getInput('file-path');
console.log(`testing ${filepath`});
// 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}`);
exec.exec('./test')
} catch (error) {
core.setFailed(error.message);
}
如何从控制台执行 javascript?
【问题讨论】:
标签: git github github-actions