feat(actions): add post-step support for composite actions
This commit is contained in:
11
.gitea/actions/with-post-step/action.yml
Normal file
11
.gitea/actions/with-post-step/action.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
name: "with-post-step"
|
||||
description: "Runs a main command and, afterwards, a post command."
|
||||
inputs:
|
||||
main: { description: "Command for the main step", required: true }
|
||||
post: { description: "Command for the post step", required: true }
|
||||
key: { description: "State key", default: POST }
|
||||
|
||||
runs:
|
||||
using: node20
|
||||
main: main.js
|
||||
post: main.js
|
18
.gitea/actions/with-post-step/main.js
Normal file
18
.gitea/actions/with-post-step/main.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const { spawn } = require("child_process");
|
||||
const { appendFileSync } = require("fs");
|
||||
const { EOL } = require("os");
|
||||
|
||||
function run(cmd) {
|
||||
const proc = spawn(cmd, { stdio: "inherit", shell: true });
|
||||
proc.on("exit", code => process.exitCode = code);
|
||||
}
|
||||
|
||||
const key = process.env.INPUT_KEY.toUpperCase();
|
||||
if (process.env[`STATE_${key}`] !== undefined) {
|
||||
// ---------- POST ----------
|
||||
run(process.env.INPUT_POST);
|
||||
} else {
|
||||
// ---------- MAIN ----------
|
||||
appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
|
||||
run(process.env.INPUT_MAIN);
|
||||
}
|
Reference in New Issue
Block a user