-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The composite action didn't work as expected (the action's `action.sh` and `build.sh` weren't accessible), so I replaced the shell script with a tiny JavaScript bootstrap, that will properly collect the action inputs and generate a simple local build.sh and calls it. Note that we couldn't use a Docker container action, because we couldn't access the host docker ending, and would need to add both docker cli and docker server to the docker container...
- Loading branch information
1 parent
3ec303d
commit 404e79d
Showing
3 changed files
with
37 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const process = require("process") | ||
const { spawn } = require("child_process") | ||
const fs = require("fs") | ||
|
||
// basic implementation of @action/core.getInput() | ||
function getInput(name) { | ||
return process.env[`INPUT_${name.toUpperCase()}`].trim() | ||
} | ||
|
||
// collect action inputs: | ||
let setupOpts = [] | ||
if (getInput("skip-login") === "true") setupOpts.push("--skip-login") | ||
if (getInput("latest") === "true") setupOpts.push("latest") | ||
|
||
let buildOpts = [], value | ||
if ((value = getInput("repository")) !== "") buildOpts.push(`-r ${value}`) | ||
if ((value = getInput("repository-suffix")) !== "") buildOpts.push(`-s ${value}`) | ||
if ((value = getInput("tag-suffix")) !== "") buildOpts.push(`-t ${value}`) | ||
if ((value = getInput("build-directory")) !== "") buildOpts.push(`-d ${value}`) | ||
if ((value = getInput("build-options")) !== "") buildOpts.push(`-o "${value}"`) | ||
|
||
// generate a local build.sh script: | ||
fs.writeFileSync("build.sh", `#! bash | ||
source ${__dirname}/build.sh | ||
dockerSetup ${setupOpts.join(" ")} | ||
echo $VERSION > VERSION | ||
dockerBuildAndPush ${buildOpts.join(" ")} | ||
`) | ||
|
||
// execute it: | ||
const build = spawn("bash", ["build.sh"], { maxBuffer: 100 * 1024 * 1024 }) | ||
build.stdout.on("data", data => { process.stdout.write(data) }) | ||
build.stderr.on("data", data => { process.stderr.write(data) }) | ||
build.on("error", error => { console.error(error) }) | ||
build.on("exit", code => { process.exit(code) }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters