Skip to content

Commit e5352bd

Browse files
committed
Refactor setup to use Node.js for Docker commands and add main and post scripts
1 parent d6d7609 commit e5352bd

File tree

5 files changed

+45
-14
lines changed

5 files changed

+45
-14
lines changed

.github/workflows/example-audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- name: Start buildcage builder
1212
id: buildcage
13-
uses: dash14/buildcage/setup@v1
13+
uses: dash14/buildcage/setup@main
1414
with:
1515
proxy_mode: audit
1616

.github/workflows/example-restrict.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- name: Start buildcage builder
1212
id: buildcage
13-
uses: dash14/buildcage/setup@v1
13+
uses: dash14/buildcage/setup@main
1414
with:
1515
proxy_mode: restrict
1616
allowed_https_domains: registry.npmjs.org

setup/action.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,8 @@ inputs:
2626
outputs:
2727
endpoint:
2828
description: "BuildKit endpoint for docker buildx create --driver remote"
29-
value: tcp://localhost:1234
3029

3130
runs:
32-
using: composite
33-
steps:
34-
- name: Start builder
35-
shell: bash
36-
env:
37-
PROXY_MODE: ${{ inputs.proxy_mode }}
38-
ALLOWED_HTTP_DOMAINS: ${{ inputs.allowed_http_domains }}
39-
ALLOWED_HTTPS_DOMAINS: ${{ inputs.allowed_https_domains }}
40-
BUILDCAGE_IMAGE: ${{ inputs.buildcage_image }}
41-
BUILDCAGE_VERSION: ${{ inputs.buildcage_version }}
42-
run: docker compose -f ${{ github.action_path }}/compose.yml up -d --pull always --no-build --wait
31+
using: node24
32+
main: main.mjs
33+
post: post.mjs

setup/main.mjs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { execFileSync } from "node:child_process";
2+
import { appendFileSync } from "node:fs";
3+
import { join, dirname } from "node:path";
4+
import { fileURLToPath } from "node:url";
5+
6+
const __dirname = dirname(fileURLToPath(import.meta.url));
7+
8+
execFileSync(
9+
"docker",
10+
[
11+
"compose",
12+
"-f", join(__dirname, "compose.yml"),
13+
"up", "-d", "--pull", "always", "--no-build", "--wait",
14+
],
15+
{
16+
stdio: "inherit",
17+
env: {
18+
...process.env,
19+
PROXY_MODE: process.env.INPUT_PROXY_MODE || "restrict",
20+
ALLOWED_HTTP_DOMAINS: process.env.INPUT_ALLOWED_HTTP_DOMAINS || "",
21+
ALLOWED_HTTPS_DOMAINS: process.env.INPUT_ALLOWED_HTTPS_DOMAINS || "",
22+
BUILDCAGE_IMAGE: process.env.INPUT_BUILDCAGE_IMAGE || "ghcr.io/dash14/buildcage",
23+
BUILDCAGE_VERSION: process.env.INPUT_BUILDCAGE_VERSION || "latest",
24+
},
25+
}
26+
);
27+
28+
// Set action output
29+
appendFileSync(process.env.GITHUB_OUTPUT, "endpoint=tcp://localhost:1234\n");

setup/post.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { execFileSync } from "node:child_process";
2+
import { join, dirname } from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
7+
execFileSync(
8+
"docker",
9+
["compose", "-f", join(__dirname, "compose.yml"), "down"],
10+
{ stdio: "inherit" }
11+
);

0 commit comments

Comments
 (0)