Skip to content

Commit

Permalink
entrypoint.js: fix script path
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Sep 13, 2023
1 parent 29365ca commit 1ecd7e9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function run(cmd) {
const key = "POST"

if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step?
run("./post");
run(__dirname+"/post");
} else { // Otherwise, this is the main step
appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
run("./main");
run(__dirname+"/main");
}
20 changes: 12 additions & 8 deletions main
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#!/bin/bash
set -eux -o pipefail
: "Argv0: $0"
dir="$(dirname "$0")"
read_action_input() {
"${dir}/read-action-input" "$1"
}
: "Clean Directories"
rm -Rf "$(./read-action-input scratch-dir)" && mkdir -p "$(./read-action-input scratch-dir)" "$(./read-action-input cache-source)"
rm -Rf "$(read_action_input scratch-dir)" && mkdir -p "$(read_action_input scratch-dir)" "$(read_action_input cache-source)"
: "Prepare Timestamp for Layer Cache Busting"
date --iso=ns | tee "$(./read-action-input cache-source)"/buildstamp
date --iso=ns | tee "$(read_action_input cache-source)"/buildstamp
: "Prepare Dancefile to Access Caches"
cat >"$(./read-action-input scratch-dir)"/Dancefile.inject <<EOF
cat >"$(read_action_input scratch-dir)"/Dancefile.inject <<EOF
FROM busybox:1
COPY buildstamp buildstamp
RUN --mount=type=cache,target="$(./read-action-input cache-target)" \
RUN --mount=type=cache,target="$(read_action_input cache-target)" \
--mount=type=bind,source=.,target=/var/dance-cache \
cp -p -R /var/dance-cache/. "$(./read-action-input cache-target)" || true
cp -p -R /var/dance-cache/. "$(read_action_input cache-target)" || true
EOF
cat "$(./read-action-input scratch-dir)"/Dancefile.inject
cat "$(read_action_input scratch-dir)"/Dancefile.inject
: "Inject Data into Docker Cache"
docker buildx build -f "$(./read-action-input scratch-dir)"/Dancefile.inject --tag dance:inject "$(./read-action-input cache-source)"
docker buildx build -f "$(read_action_input scratch-dir)"/Dancefile.inject --tag dance:inject "$(read_action_input cache-source)"
: "Clean Directories"
sudo rm -rf "$(./read-action-input cache-source)"
sudo rm -rf "$(read_action_input cache-source)"
22 changes: 13 additions & 9 deletions post
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
#!/bin/bash
set -eux -o pipefail
: "Argv0: $0"
dir="$(dirname "$0")"
read_action_input() {
"${dir}/read-action-input" "$1"
}
: "Prepare Timestamp for Layer Cache Busting"
date --iso=ns | tee "$(./read-action-input scratch-dir)"/buildstamp
date --iso=ns | tee "$(read_action_input scratch-dir)"/buildstamp
: "Prepare Dancefile to Access Caches"
cat >"$(./read-action-input scratch-dir)"/Dancefile.extract <<EOF
cat >"$(read_action_input scratch-dir)"/Dancefile.extract <<EOF
FROM busybox:1
COPY buildstamp buildstamp
RUN --mount=type=cache,target="$(./read-action-input cache-target)" \
RUN --mount=type=cache,target="$(read_action_input cache-target)" \
mkdir -p /var/dance-cache/ \
&& cp -p -R "$(./read-action-input cache-target)"/. /var/dance-cache/ || true
&& cp -p -R "$(read_action_input cache-target)"/. /var/dance-cache/ || true
EOF
cat "$(./read-action-input scratch-dir)"/Dancefile.extract
cat "$(read_action_input scratch-dir)"/Dancefile.extract
: "Extract Data into Docker Image"
docker buildx build -f "$(./read-action-input scratch-dir)"/Dancefile.extract --tag dance:extract --load "$(./read-action-input scratch-dir)"
docker buildx build -f "$(read_action_input scratch-dir)"/Dancefile.extract --tag dance:extract --load "$(read_action_input scratch-dir)"
: "Create Extraction Image"
docker rm -f cache-container && docker create -ti --name cache-container dance:extract
: "Unpack Docker Image into Scratch"
docker cp -L cache-container:/var/dance-cache - | tar -H posix -x -C "$(./read-action-input scratch-dir)"
docker cp -L cache-container:/var/dance-cache - | tar -H posix -x -C "$(read_action_input scratch-dir)"
: "Move Cache into Its Place"
sudo rm -rf "$(./read-action-input cache-source)"
mv "$(./read-action-input scratch-dir)"/dance-cache "$(./read-action-input cache-source)"
sudo rm -rf "$(read_action_input cache-source)"
mv "$(read_action_input scratch-dir)"/dance-cache "$(read_action_input cache-source)"

0 comments on commit 1ecd7e9

Please sign in to comment.