Skip to content

Commit a4bf073

Browse files
authored
Merge pull request #5 from AkihiroSuda/dev
entrypoint.js: fix script path
2 parents 29365ca + 1ecd7e9 commit a4bf073

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

entrypoint.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function run(cmd) {
4242
const key = "POST"
4343

4444
if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step?
45-
run("./post");
45+
run(__dirname+"/post");
4646
} else { // Otherwise, this is the main step
4747
appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
48-
run("./main");
48+
run(__dirname+"/main");
4949
}

main

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
#!/bin/bash
22
set -eux -o pipefail
33
: "Argv0: $0"
4+
dir="$(dirname "$0")"
5+
read_action_input() {
6+
"${dir}/read-action-input" "$1"
7+
}
48
: "Clean Directories"
5-
rm -Rf "$(./read-action-input scratch-dir)" && mkdir -p "$(./read-action-input scratch-dir)" "$(./read-action-input cache-source)"
9+
rm -Rf "$(read_action_input scratch-dir)" && mkdir -p "$(read_action_input scratch-dir)" "$(read_action_input cache-source)"
610
: "Prepare Timestamp for Layer Cache Busting"
7-
date --iso=ns | tee "$(./read-action-input cache-source)"/buildstamp
11+
date --iso=ns | tee "$(read_action_input cache-source)"/buildstamp
812
: "Prepare Dancefile to Access Caches"
9-
cat >"$(./read-action-input scratch-dir)"/Dancefile.inject <<EOF
13+
cat >"$(read_action_input scratch-dir)"/Dancefile.inject <<EOF
1014
FROM busybox:1
1115
COPY buildstamp buildstamp
12-
RUN --mount=type=cache,target="$(./read-action-input cache-target)" \
16+
RUN --mount=type=cache,target="$(read_action_input cache-target)" \
1317
--mount=type=bind,source=.,target=/var/dance-cache \
14-
cp -p -R /var/dance-cache/. "$(./read-action-input cache-target)" || true
18+
cp -p -R /var/dance-cache/. "$(read_action_input cache-target)" || true
1519
EOF
16-
cat "$(./read-action-input scratch-dir)"/Dancefile.inject
20+
cat "$(read_action_input scratch-dir)"/Dancefile.inject
1721
: "Inject Data into Docker Cache"
18-
docker buildx build -f "$(./read-action-input scratch-dir)"/Dancefile.inject --tag dance:inject "$(./read-action-input cache-source)"
22+
docker buildx build -f "$(read_action_input scratch-dir)"/Dancefile.inject --tag dance:inject "$(read_action_input cache-source)"
1923
: "Clean Directories"
20-
sudo rm -rf "$(./read-action-input cache-source)"
24+
sudo rm -rf "$(read_action_input cache-source)"

post

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
#!/bin/bash
22
set -eux -o pipefail
33
: "Argv0: $0"
4+
dir="$(dirname "$0")"
5+
read_action_input() {
6+
"${dir}/read-action-input" "$1"
7+
}
48
: "Prepare Timestamp for Layer Cache Busting"
5-
date --iso=ns | tee "$(./read-action-input scratch-dir)"/buildstamp
9+
date --iso=ns | tee "$(read_action_input scratch-dir)"/buildstamp
610
: "Prepare Dancefile to Access Caches"
7-
cat >"$(./read-action-input scratch-dir)"/Dancefile.extract <<EOF
11+
cat >"$(read_action_input scratch-dir)"/Dancefile.extract <<EOF
812
FROM busybox:1
913
COPY buildstamp buildstamp
10-
RUN --mount=type=cache,target="$(./read-action-input cache-target)" \
14+
RUN --mount=type=cache,target="$(read_action_input cache-target)" \
1115
mkdir -p /var/dance-cache/ \
12-
&& cp -p -R "$(./read-action-input cache-target)"/. /var/dance-cache/ || true
16+
&& cp -p -R "$(read_action_input cache-target)"/. /var/dance-cache/ || true
1317
EOF
14-
cat "$(./read-action-input scratch-dir)"/Dancefile.extract
18+
cat "$(read_action_input scratch-dir)"/Dancefile.extract
1519
: "Extract Data into Docker Image"
16-
docker buildx build -f "$(./read-action-input scratch-dir)"/Dancefile.extract --tag dance:extract --load "$(./read-action-input scratch-dir)"
20+
docker buildx build -f "$(read_action_input scratch-dir)"/Dancefile.extract --tag dance:extract --load "$(read_action_input scratch-dir)"
1721
: "Create Extraction Image"
1822
docker rm -f cache-container && docker create -ti --name cache-container dance:extract
1923
: "Unpack Docker Image into Scratch"
20-
docker cp -L cache-container:/var/dance-cache - | tar -H posix -x -C "$(./read-action-input scratch-dir)"
24+
docker cp -L cache-container:/var/dance-cache - | tar -H posix -x -C "$(read_action_input scratch-dir)"
2125
: "Move Cache into Its Place"
22-
sudo rm -rf "$(./read-action-input cache-source)"
23-
mv "$(./read-action-input scratch-dir)"/dance-cache "$(./read-action-input cache-source)"
26+
sudo rm -rf "$(read_action_input cache-source)"
27+
mv "$(read_action_input scratch-dir)"/dance-cache "$(read_action_input cache-source)"

0 commit comments

Comments
 (0)