Skip to content

Commit

Permalink
chore: cleanup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 committed Jan 6, 2025
1 parent b87b2b6 commit ae6eb61
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 123 deletions.
35 changes: 18 additions & 17 deletions .github/actions/build-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inputs:
description: "The tags to apply to the image"
required: true
build-args:
description: "Build arguments to pass to the Docker build"
description: "Build arguments to pass to the Docker build. Newline separated list of key=value pairs."
required: false
default: ""
builder:
Expand Down Expand Up @@ -46,22 +46,22 @@ runs:
if: ${{ inputs.builder == 'podman' }}
id: build-podman
shell: bash
env:
BUILD_ARGS_INPUT: ${{ inputs.build-args }}
run: |
BUILD_ARG_FLAGS=""
if [ -n "${{ inputs.build-args }}" ]; then
IFS=' ' read -r -a build_args_array <<< "${{ inputs.build-args }}"
for build_arg in "${build_args_array[@]}"; do
BUILD_ARG_FLAGS+="--build-arg $build_arg "
done
fi
BUILD_ARGS=()
while IFS = read -r build_arg; do
BUILD_ARGS+=("--build-arg $build_arg")
done <<< "${BUILD_ARGS_INPUT}"
TAGS_FLAGS=""
IFS=' ' read -r -a tag_array <<< "${{ inputs.image-tags }}"
for tag in "${tag_array[@]}"; do
TAGS_FLAGS+="--tag ${{ inputs.image-name }}:$tag "
done
podman build \
$BUILD_ARG_FLAGS \
"${BUILD_ARGS[@]}" \
$TAGS_FLAGS \
-f ${{ inputs.dockerfile }} \
${{ inputs.context }}
Expand All @@ -73,14 +73,15 @@ runs:
if: ${{ inputs.builder == 'docker' }}
id: build-docker
shell: bash
env:
BUILD_ARGS_INPUT: ${{ inputs.build-args }}
run: |
BUILD_ARG_FLAGS=""
if [ -n "${{ inputs.build-args }}" ]; then
IFS=' ' read -r -a build_args_array <<< "${{ inputs.build-args }}"
for build_arg in "${build_args_array[@]}"; do
BUILD_ARG_FLAGS+="--build-arg $build_arg "
done
fi
set -ex
BUILD_ARGS=()
while IFS = read -r build_arg; do
BUILD_ARGS+=("--build-arg $build_arg")
done <<< "${BUILD_ARGS_INPUT}"
TAGS_FLAGS=""
IFS=' ' read -r -a tag_array <<< "${{ inputs.image-tags }}"
Expand All @@ -89,7 +90,7 @@ runs:
done
docker build \
$BUILD_ARG_FLAGS \
${BUILD_ARGS[@]} \
$TAGS_FLAGS \
-f ${{ inputs.dockerfile }} \
${{ inputs.context }}
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Maximize build space
uses: ublue-os/remove-unwanted-software@517622d6452028f266b7ba4cc9a123b5f58a6b53 # v7
with:
remove-codeql: true
# - name: Maximize build space
# uses: ublue-os/remove-unwanted-software@517622d6452028f266b7ba4cc9a123b5f58a6b53 # v7
# with:
# remove-codeql: true

- name: Generate Image Tags
uses: ./.github/actions/generate-image-tags
Expand Down Expand Up @@ -147,10 +147,10 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Maximize build space
uses: ublue-os/remove-unwanted-software@517622d6452028f266b7ba4cc9a123b5f58a6b53 # v7
with:
remove-codeql: true
# - name: Maximize build space
# uses: ublue-os/remove-unwanted-software@517622d6452028f266b7ba4cc9a123b5f58a6b53 # v7
# with:
# remove-codeql: true

- name: Generate Image Tags
uses: ./.github/actions/generate-image-tags
Expand Down
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY files/_${FEDORA_EDITION} /
COPY scripts/ /tmp/scripts

RUN chmod +x /tmp/scripts/*.sh /tmp/scripts/_${FEDORA_EDITION}/*.sh && \
/tmp/scripts/setup.sh --version ${FEDORA_VERSION} --base ${FEDORA_EDITION} --coreos-kernel ${COREOS_KERNEL} && \
/tmp/scripts/cleanup.sh --version ${FEDORA_VERSION} --base ${FEDORA_EDITION} \
/tmp/scripts/setup.sh --base ${FEDORA_EDITION} && \
/tmp/scripts/cleanup.sh --base ${FEDORA_EDITION} \
&& \
bootc container lint
2 changes: 1 addition & 1 deletion Containerfile.nvidia
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG FEDORA_VERSION=40
ARG FEDORA_VERSION=41
ARG FEDORA_EDITION=base

ARG BASE_IMAGE=ghcr.io/rsturla/eternal-linux/main/${FEDORA_EDITION}
Expand Down
20 changes: 1 addition & 19 deletions scripts/_base/000-replace-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,7 @@

set -euox pipefail

COREOS_KERNEL=""
FEDORA_VERSION=""

while [[ $# -gt 0 ]]; do
case "$1" in
--version)
FEDORA_VERSION="$2"
shift 2
;;
--coreos-kernel)
COREOS_KERNEL="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done
COREOS_KERNEL=${COREOS_KERNEL}

if [[ "$COREOS_KERNEL" == "N/A" ]]; then
exit 0
Expand Down
34 changes: 0 additions & 34 deletions scripts/_base/009-bootc.sh

This file was deleted.

53 changes: 11 additions & 42 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,57 +1,26 @@
#!/usr/bin/env bash

set -euox pipefail
set -euo pipefail

BASE=""
FEDORA_VERSION=""
COREOS_KERNEL=""

while [[ $# -gt 0 ]]; do
case "$1" in
--base)
BASE="$2"
shift 2
;;
--version)
FEDORA_VERSION="$2"
shift 2
;;
--coreos-kernel)
COREOS_KERNEL="$2"
shift 2
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
done

if [[ -z "$BASE" ]]; then
echo "--base flag is required"
exit 1
fi

if [[ -z "$FEDORA_VERSION" ]]; then
echo "--version flag is required"
exit 1
fi
FEDORA_EDITION=${FEDORA_EDITION}

for script in /tmp/scripts/_base/*.sh; do
if [[ -f "$script" ]]; then
echo "Running $script"
bash "$script" --version "$FEDORA_VERSION" --coreos-kernel "$COREOS_KERNEL"
echo "::group::===$(basename "$script")==="
bash "$script"
echo "::endgroup::"
fi
done

# If the image is BASE, then we don't need to run the same scripts again
if [[ "$BASE" == "base" ]]; then
# If the edition is BASE, then we don't need to run the same scripts again
if [[ "$FEDORA_EDITION" == "base" ]]; then
exit 0
fi

for script in /tmp/scripts/_$BASE/*.sh; do
for script in /tmp/scripts/_$FEDORA_EDITION/*.sh; do
if [[ -f "$script" ]]; then
echo "Running $script"
bash "$script" --version "$FEDORA_VERSION"
echo "::group::===$(basename "$script")==="
bash "$script"
echo "::endgroup::"
fi
done

0 comments on commit ae6eb61

Please sign in to comment.