Skip to content

Commit

Permalink
move some stuff around
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Dolitsky <[email protected]>
  • Loading branch information
jdolitsky committed Jul 17, 2023
1 parent 63ee40d commit 7b7e0d6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 30 deletions.
55 changes: 35 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,33 @@ inputs:
packages:
description: "Comma-separated list of Wolfi packages to install"
required: true
default: "grype"
command:
description: "Command to run"
required: true
default: "echo \"Hello from wolfi-act!\""
apko-image:
description: "The apko image to build with"
required: true
default: "ghcr.io/wolfi-dev/apko:latest"
debug:
description: "Whether or not to add debug logging"
required: false
default: 'false'
runs:
using: "composite"
steps:
- shell: bash
run: |
set -ex
trap "rm -f wolfi-act.apko.config wolfi-act.tar" EXIT
set -e
cat >./wolfi-act.apko.config <<EOL
build_img_mute="2>/dev/null"
load_img_mute=">/dev/null"
if [[ '${{inputs.debug}}' == 'true' ]]; then
build_img_mute=""
load_img_mute=""
set -x
fi
cat >./wolfi-act.apko.config.yaml <<EOL
contents:
repositories:
- https://packages.wolfi.dev/os
Expand All @@ -36,21 +45,27 @@ runs:
- ${{ inputs.packages }}
EOL
printf "Building ephemeral container image from Wolfi packages... "
docker run --rm \
-v ${PWD}:/work \
-w /work \
${{ inputs.apko-image }} \
build \
--build-arch x86_64 \
--sbom=false \
wolfi-act.apko.config \
wolfi-act:latest \
wolfi-act.tar
-v ${PWD}:/work \
-w /work \
'${{ inputs.apko-image }}' \
build \
--arch=x86_64 \
--sbom=false \
wolfi-act.apko.config.yaml \
wolfi-act:latest \
wolfi-act.tar ${build_img_mute}
echo "done."
docker load < wolfi-act.tar
printf "Loading ephemeral container image into Docker... "
docker load < wolfi-act.tar ${load_img_mute}
echo "done."
docker run --rm --platform linux/amd64 \
-v ${PWD}:/work \
-w /work \
wolfi-act:latest \
bash -exc "${{ inputs.command }}"
echo "Running the following command in ephemeral container image: ${CMD}"
echo "Output:"
docker run -i --rm --platform linux/amd64 \
-v ${PWD}:/work \
-w /work \
wolfi-act:latest \
bash -ec "${CMD}"
25 changes: 15 additions & 10 deletions wolfi-act.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash

set -ex
trap "rm -f wolfi-act.apko.config wolfi-act.tar" EXIT
set -e
trap "rm -f wolfi-act.apko.config.yaml wolfi-act.tar" EXIT

CMD=$@
[[ "${CMD}" != "" ]] || CMD="echo \"Hello from wolfi-act!\""

cat >./wolfi-act.apko.config <<EOL
cat >./wolfi-act.apko.config.yaml <<EOL
contents:
repositories:
- https://packages.wolfi.dev/os
Expand All @@ -17,24 +17,29 @@ contents:
- wolfi-baselayout
- busybox
- bash
- grype
EOL

printf "Building ephemeral container image from Wolfi packages... "
docker run --rm \
-v ${PWD}:/work \
-w /work \
ghcr.io/wolfi-dev/apko:latest \
build \
--build-arch x86_64 \
--arch x86_64 \
--sbom=false \
wolfi-act.apko.config \
wolfi-act.apko.config.yaml \
wolfi-act:latest \
wolfi-act.tar
wolfi-act.tar 2>/dev/null
echo "done."

docker load < wolfi-act.tar
printf "Loading ephemeral container image into Docker... "
docker load < wolfi-act.tar >/dev/null
echo "done."

docker run --rm --platform linux/amd64 \
echo "Running the following command in ephemeral container image: ${CMD}"
echo "Output:"
docker run -i --rm --platform linux/amd64 \
-v ${PWD}:/work \
-w /work \
wolfi-act:latest \
bash -exc "${CMD}"
bash -ec "${CMD}"

0 comments on commit 7b7e0d6

Please sign in to comment.