Skip to content

Commit

Permalink
Merge pull request #2 from wolfi-dev/cleanup
Browse files Browse the repository at this point in the history
cleanup
  • Loading branch information
jdolitsky authored Mar 26, 2024
2 parents dd6ff7d + 6c503ae commit c7bc05c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 51 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ on:
branches:
- main
workflow_dispatch: {}

env:
IMAGE_REPO: ghcr.io/${{ github.repository }}/wolfi-act-test
APKO_CONFIG: https://raw.githubusercontent.com/chainguard-images/images/main/images/maven/configs/openjdk-17.apko.yaml
APKO_CONFIG: https://raw.githubusercontent.com/chainguard-images/images/main/images/maven/config/template.apko.yaml
GHCR_USER: ${{ github.repository_owner }}
GHCR_PASS: ${{ github.token }}

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -33,7 +35,7 @@ jobs:
apko publish apko.yaml "${IMAGE_REPO}" \
--repository-append=https://packages.wolfi.dev/os \
--keyring-append=https://packages.wolfi.dev/os/wolfi-signing.rsa.pub \
--package-append=wolfi-baselayout \
--package-append=wolfi-baselayout,maven,openjdk-17,openjdk-17-default-jvm \
--arch=x86_64,aarch64 \
--image-refs=apko.images.txt | tee apko.index.txt
index_digest="$(cat apko.index.txt)"
Expand All @@ -51,4 +53,4 @@ jobs:
- name: Make sure the image runs
run: |
set -x
docker run --rm "${IMAGE_REPO}:latest" --version
docker run --rm -e JAVA_HOME=/usr/lib/jvm/java-17-openjdk "${IMAGE_REPO}:latest" --version
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: ci

on:
pull_request:

env:
IMAGE_REPO: ttl.sh/test-${{ github.job }}-${{ github.run_id }}
APKO_CONFIG: https://raw.githubusercontent.com/chainguard-images/images/main/images/maven/configs/openjdk-17.apko.yaml
APKO_CONFIG: https://raw.githubusercontent.com/chainguard-images/images/main/images/maven/config/template.apko.yaml

jobs:
ci:
Expand All @@ -27,7 +28,7 @@ jobs:
apko publish apko.yaml "${IMAGE_REPO}" \
--repository-append=https://packages.wolfi.dev/os \
--keyring-append=https://packages.wolfi.dev/os/wolfi-signing.rsa.pub \
--package-append=wolfi-baselayout \
--package-append=wolfi-baselayout,maven,openjdk-17,openjdk-17-default-jvm \
--arch=x86_64,aarch64 \
--image-refs=apko.images.txt | tee apko.index.txt
index_digest="$(cat apko.index.txt)"
Expand All @@ -42,7 +43,7 @@ jobs:
- name: Make sure the image runs
run: |
set -x
docker run --rm "${IMAGE_REPO}:latest" --version
docker run --rm -e JAVA_HOME=/usr/lib/jvm/java-17-openjdk "${IMAGE_REPO}:latest" --version
ci-debug:
runs-on: ubuntu-latest
Expand All @@ -65,7 +66,7 @@ jobs:
apko publish apko.yaml "${IMAGE_REPO}" \
--repository-append=https://packages.wolfi.dev/os \
--keyring-append=https://packages.wolfi.dev/os/wolfi-signing.rsa.pub \
--package-append=wolfi-baselayout \
--package-append=wolfi-baselayout,maven,openjdk-17,openjdk-17-default-jvm \
--arch=x86_64,aarch64 \
--image-refs=apko.images.txt | tee apko.index.txt
index_digest="$(cat apko.index.txt)"
Expand All @@ -80,4 +81,4 @@ jobs:
- name: Make sure the image runs
run: |
set -x
docker run --rm "${IMAGE_REPO}:latest" --version
docker run --rm -e JAVA_HOME=/usr/lib/jvm/java-17-openjdk "${IMAGE_REPO}:latest" --version
65 changes: 22 additions & 43 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ runs:
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
Expand Down Expand Up @@ -55,56 +59,31 @@ runs:
fi
printf "[πŸ™] Building ephemeral container image from Wolfi packages... "
if [[ "${debug}" == "true" ]]; then
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
else
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 2>/dev/null
fi
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... "
if [[ "${debug}" == "true" ]]; then
docker load < wolfi-act.tar
else
docker load < wolfi-act.tar >/dev/null
fi
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:"
if [[ "${debug}" == "true" ]]; then
docker run -i --rm --platform linux/amd64 \
-v ${PWD}:/work \
-w /work \
--env-file wolfi-act.github.env \
wolfi-act:latest-amd64 \
bash -exc '${{ inputs.command }}'
else
docker run -i --rm --platform linux/amd64 \
-v ${PWD}:/work \
-w /work \
--env-file wolfi-act.github.env \
wolfi-act:latest-amd64 \
bash -ec '${{ inputs.command }}'
fi
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 }}'

0 comments on commit c7bc05c

Please sign in to comment.