Skip to content

Commit

Permalink
Concierge branch
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Oct 11, 2024
1 parent 79bd232 commit 834965c
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 16,956 deletions.
23 changes: 23 additions & 0 deletions .github/actions/with-post-steps/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copied from: https://github.com/pyTooling/Actions/blob/main/with-post-step/action.yml
name: With post step

description: "Generic JS Action to execute a main command and set a command as a post step."

inputs:
main:
description: "Main command/script."
required: true
post:
description: "Post command/script."
required: true
key:
description: "Name of the state variable used to detect the post step."
required: false
default: POST

runs:
using: "node20"
main: "main.js"
post: "main.js"


20 changes: 20 additions & 0 deletions .github/actions/with-post-steps/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Ref: https://github.com/pyTooling/Actions/blob/main/with-post-step/main.js
const { spawn } = require("child_process");
const { appendFileSync } = require("fs");
const { EOL } = require("os");

function run(cmd) {
const subprocess = spawn(cmd, { stdio: "inherit", shell: true });
subprocess.on("exit", (exitCode) => {
process.exitCode = exitCode;
});
}

const key = process.env.INPUT_KEY.toUpperCase();

if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step?
run(process.env.INPUT_POST);
} else { // Otherwise, this is the main step
appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
run(process.env.INPUT_MAIN);
}
10 changes: 7 additions & 3 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ inputs:
container-registry-url:
description: "Container registry to use"
runs:
using: "node20"
main: "dist/bootstrap/index.js"
post: "dist/cleanup/index.js"
using: "composite"
steps:
- name: Cache
uses: ./.github/actions/with-post-steps
with:
main: "src/bootstrap/main.sh"
post: "src/cleanup/main.sh"
branding:
icon: "play"
color: "blue"
Loading

0 comments on commit 834965c

Please sign in to comment.