-
Notifications
You must be signed in to change notification settings - Fork 4
/
action.yml
89 lines (79 loc) · 2.52 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: "wolfi-act"
description: "Dynamic GitHub Actions from Wolfi packages"
inputs:
packages:
description: "Comma-separated list of Wolfi packages to install"
required: true
command:
description: "Command to run"
required: true
apko-image:
description: "The apko image to build with"
required: true
default: "cgr.dev/chainguard/apko:latest"
debug:
description: "Whether or not to add debug logging"
required: false
default: 'false'
runs:
using: "composite"
steps:
- shell: bash
run: |
set -e
debug_args=
debug_args_image="-exc"
debug='${{inputs.debug}}'
if [[ "${debug}" == "true" ]]; then
echo "[🐙] Enabling debug logging."
set -x
debug_args="2>/dev/null"
debug_args_image="-ec"
fi
if [[ '${{inputs.command}}' == '' ]]; then
echo "[🐙] Missing input: command"
exit 1
fi
cat >./wolfi-act.apko.config.yaml <<EOL
contents:
repositories:
- https://packages.wolfi.dev/os
keyring:
- https://packages.wolfi.dev/os/wolfi-signing.rsa.pub
packages:
- ca-certificates-bundle
- wolfi-baselayout
- busybox
- bash
EOL
packages='${{inputs.packages}}'
if [[ "${packages}" != "" ]]; then
for package in $(echo "${packages}" | sed 's/,/\n/g'); do
echo " - ${package}" >> ./wolfi-act.apko.config.yaml
done
fi
printf "[🐙] Building ephemeral container image from Wolfi packages... "
eval docker run --rm \
-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 "${debug_args}"
echo "done."
printf "[🐙] Loading ephemeral container image into Docker... "
eval docker load < wolfi-act.tar "${debug_args}"
echo "done."
env > wolfi-act.github.env
echo "[🐙] Running the following command in ephemeral container image:"
echo '${{ inputs.command }}'
echo "[🐙] Output:"
docker run -i --rm --platform linux/amd64 \
-v ${PWD}:/work \
-w /work \
--env-file wolfi-act.github.env \
wolfi-act:latest-amd64 \
bash "${debug_args_image}" '${{ inputs.command }}'