Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Container Copying to Directory #41

Merged
merged 59 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
3d04223
fix: initial attempt
noelmiller Mar 5, 2024
d1d9713
fix: updated volume and added output_dir to inputs
noelmiller Mar 5, 2024
3536ef5
fix: added output command to add to github outputs
noelmiller Mar 5, 2024
44c82b5
fix: formatting
noelmiller Mar 5, 2024
84995c0
fix: set-output
noelmiller Mar 5, 2024
9ca8ff3
replaced tab with spaces
noelmiller Mar 5, 2024
4f5dd41
fixed: again...
noelmiller Mar 5, 2024
88c39b0
Merge branch 'main' into fix_container_dir
JasonN3 Mar 5, 2024
c2fb744
fix: added backslash
noelmiller Mar 5, 2024
0067705
fix: added default
noelmiller Mar 5, 2024
3490ea2
fix: rename ISO and Upload
noelmiller Mar 5, 2024
1f13050
fix: use whole path
noelmiller Mar 6, 2024
fd273e0
fix: simplified build process
noelmiller Mar 6, 2024
01d1222
fix: fixed default
noelmiller Mar 6, 2024
288976f
fix: added move to entrypoint
noelmiller Mar 6, 2024
cf2f136
fix: removed OUTPUT_DIR
noelmiller Mar 6, 2024
7a639d6
fix: missed $
noelmiller Mar 6, 2024
f06a0ad
feat: added ISO_NAME as param
noelmiller Mar 6, 2024
fb248cd
fix: added env to job that needs it
noelmiller Mar 6, 2024
ddb61d8
fix: added env to both places it is needed
noelmiller Mar 6, 2024
8cafb5b
fix: removed default
noelmiller Mar 6, 2024
3fd50d4
fix: variable names
noelmiller Mar 6, 2024
a51e4d5
fix: deduplicated env
noelmiller Mar 6, 2024
36f4bf1
fix: moved env before needs
noelmiller Mar 6, 2024
f19c5c7
fix: removed whitespace
noelmiller Mar 6, 2024
b528b8a
fix: generate environment variable for ISO_NAME
noelmiller Mar 6, 2024
f15867f
fix: added mv command to makefile
noelmiller Mar 6, 2024
87508ad
feat: added sha256 checksum generation
noelmiller Mar 6, 2024
2387d11
fix: spelling
noelmiller Mar 6, 2024
72368ef
fix: issues with sha256sum finding iso
noelmiller Mar 6, 2024
9b39567
fix: adding ls command to determine if relative path is working
noelmiller Mar 6, 2024
7b11754
fixed cd issue
noelmiller Mar 6, 2024
70be95c
fix: updated action to use outputs and build-and-test to use outputs
noelmiller Mar 6, 2024
3463aaf
fix: updated README
noelmiller Mar 6, 2024
b9e35f3
fix: added output information to README
noelmiller Mar 6, 2024
e3f6371
Merge branch 'main' into fix_container_dir
noelmiller Mar 7, 2024
7272126
fix: changes requested
noelmiller Mar 7, 2024
0404361
fix: code style
noelmiller Mar 7, 2024
468c599
fix: action and entrypoint
noelmiller Mar 7, 2024
e72ffb5
fix: using output-directory and updated documentation
noelmiller Mar 7, 2024
5e3ff77
chore: added additional context about the output file
noelmiller Mar 7, 2024
291f17f
chore: fixed spelling
noelmiller Mar 7, 2024
ebed693
fix: fixed id and removed trailing slash
noelmiller Mar 7, 2024
96df7ee
fix: fixed test variables
noelmiller Mar 7, 2024
e8f1fd3
fix changes
JasonN3 Mar 7, 2024
ac1abc0
fix rename
JasonN3 Mar 7, 2024
7645177
force as string
JasonN3 Mar 7, 2024
d78aeb1
stop github from processing strings
JasonN3 Mar 7, 2024
90e5f67
fix: spacing and comment
noelmiller Mar 7, 2024
b7d07f0
fix: fixed up docs and alphabetized inputs
noelmiller Mar 7, 2024
b329b2a
fix: missing underscores
noelmiller Mar 7, 2024
d109d4a
fix: name
noelmiller Mar 7, 2024
c1bf1fd
chore: fixup README
noelmiller Mar 7, 2024
3857986
add iso_path
JasonN3 Mar 7, 2024
60ecaa5
chore: update documentation
noelmiller Mar 7, 2024
87a7b37
fix: name of checksum
noelmiller Mar 7, 2024
c4456b0
eww
JasonN3 Mar 7, 2024
56719cc
Update README.md
JasonN3 Mar 8, 2024
cafc4ef
match case
JasonN3 Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ env:
SECURE_BOOT_KEY_URL: 'https://github.com/ublue-os/akmods/raw/main/certs/public_key.der'
ENROLLMENT_PASSWORD: 'container-installer'


jobs:
build-container:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -47,7 +46,7 @@ jobs:
with:
containerfiles: Containerfile
tags: ${{ steps.meta.outputs.tags }}

- name: Push image
uses: redhat-actions/push-to-registry@v2
with:
Expand All @@ -56,7 +55,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ github.token }}


build-and-push-iso:
runs-on: ubuntu-latest
needs:
Expand All @@ -65,6 +63,10 @@ jobs:
contents: read
packages: write
steps:
- name: Set Environment Variables
run: |
echo "ISO_NAME=${{ env.IMAGE_NAME }}-${{ env.VERSION }}" >> $GITHUB_ENV

- name: Checkout repo
uses: actions/checkout@v4

Expand All @@ -84,6 +86,7 @@ jobs:

- name: Build ISO with new container
uses: ./
id: build
with:
arch: ${{ env.ARCH}}
image_name: ${{ env.IMAGE_NAME}}
Expand All @@ -92,17 +95,16 @@ jobs:
variant: ${{ env.VARIANT }}
secure_boot_key_url: ${{ env.SECURE_BOOT_KEY_URL }}
enrollment_password: ${{ env.ENROLLMENT_PASSWORD }}

- name: Rename ISO
run: |
mv build/deploy.iso build/${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
iso_name: ${{ env.ISO_NAME }}

- name: Upload ISO as artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
path: build/*.iso
name: ${{ env.ISO_NAME }}.iso
path: |
${{ steps.build.outputs.iso-path }}
${{ steps.build.outputs.checksum-path }}
if-no-files-found: error
retention-days: 0
compression-level: 0
Expand Down
1 change: 1 addition & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ENV VERSION="${VERSION}"
ENV WEB_UI="false"

RUN mkdir /build-container-installer

COPY / /build-container-installer/

WORKDIR /build-container-installer
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ENROLLMENT_PASSWORD =
SECURE_BOOT_KEY_URL =
ADDITIONAL_TEMPLATES =
ROOTFS_SIZE = 4
ISO_NAME = $(IMAGE_NAME)-$(IMAGE_TAG)

# Generated vars
## Formatting = _UPPERCASE
Expand All @@ -33,12 +34,14 @@ ifeq ($(WEB_UI),true)
_LORAX_ARGS += -i anaconda-webui
endif

# Step 7: Buid end ISO
# Step 7: Build end ISO
## Default action
build/deploy.iso: boot.iso container/$(IMAGE_NAME)-$(IMAGE_TAG) xorriso/input.txt
mkdir $(_BASE_DIR)/build || true
xorriso -dialog on < $(_BASE_DIR)/xorriso/input.txt
implantisomd5 build/deploy.iso
mv build/deploy.iso build/$(ISO_NAME).iso
JasonN3 marked this conversation as resolved.
Show resolved Hide resolved
cd build && sha256sum $(ISO_NAME).iso > $(ISO_NAME)-CHECKSUM

# Step 1: Generate Lorax Templates
lorax_templates/post_%.tmpl: lorax_templates/scripts/post/%
Expand Down Expand Up @@ -174,7 +177,7 @@ clean:
rm -f $(_BASE_DIR)/*.log || true

install-deps:
dnf install -y lorax xorriso skopeo
dnf install -y lorax xorriso skopeo coreutils

test-iso:
$(eval _TESTS = $(filter-out README.md,$(shell ls tests/iso)))
Expand Down
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,34 @@ This action is designed to be called from a GitHub workflow using the following
```yaml
- name: Build ISO
uses: jasonn3/build-container-installer/v1.0.0
id: build
with:
arch: ${{ env.ARCH}}
image_name: ${{ env.IMAGE_NAME}}
image_repo: ${{ env.IMAGE_REPO}}
version: ${{ env.VERSION }}
variant: ${{ env.VARIANT }}

# This example is for uploading your ISO as a Github artifact. You can do something similar using any cloud storage, so long as you copy the output
- name: Upload ISO as artifact
id: upload
uses: actions/upload-artifact@v4
with:
name: my_iso.iso
path: |
${{ steps.build.outputs.iso_path }}
${{ steps.build.outputs.checksum-path }}
if-no-files-found: error
retention-days: 0
compression-level: 0
```

See [Customizing](#customizing) for information about customizing the ISO that gets created using `with`

## Customizing
The following variables can be used to customize the created ISO.

### Inputs
| Variable | Description | Default Value |
| ----------------- | -------------------------------------------------------- | ------------------------------ |
| ARCH | Architecture for image to build | x86_64 |
Expand All @@ -31,10 +46,19 @@ The following variables can be used to customize the created ISO.
| EXTRA_BOOT_PARAMS | Extra params used by grub to boot the anaconda installer | \[empty\] |
| VARIANT | Source container variant\* | Server |
| WEB_UI | Enable Anaconda WebUI (experimental) | false |
| ISO_NAME | Name of the ISO you wish to output when completed | IMAGE_NAME-IMAGE_TAG |

Available options for VARIANT can be found by running `dnf provides system-release`.
Variant will be the third item in the package name. Example: `fedora-release-kinoite-39-34.noarch` will be kinoite

### Outputs
| Variable | Description | Usage |
| ----------------- | -------------------------------------------------------- | ------------------------------------------------ |
| iso-path | Path to ISO file that the action creates | ${{ steps.YOUR_ID_FOR_ACTION.outputs.iso_path }} |
| checksum-path | Path to the checksum file that the action creates | ${{ steps.YOUR_ID_FOR_ACTION.outputs.iso_path }} |

For outputs, see example above.

## Development
### Makefile
The Makefile contains all of the commands that are run in the action. There are separate targets for each file generated, however `make` can be used to generate the final image and `make clean` can be used to clean up the workspace. The resulting ISO will be stored in the `build` directory.
Expand All @@ -55,12 +79,12 @@ Examples:

Building an ISO to install Fedora 38
```bash
docker run --rm --privileged --volume .:/build-container-installer/build -e VERSION=38 -e IMAGE_NAME=base -e IMAGE_TAG=38 -e VARIANT=Server ghcr.io/jasonn3/build-container-installer:latest
docker run --rm --privileged --volume .:/build-container-installer/build ghcr.io/jasonn3/build-container-installer:latest VERSION=38 IMAGE_NAME=base IMAGE_TAG=38 VARIANT=Server
```

Building an ISO to install Fedora 39
```bash
docker run --rm --privileged --volume .:/build-container-installer/build -e VERSION=39 -e IMAGE_NAME=base -e IMAGE_TAG=39 -e VARIANT=Server ghcr.io/jasonn3/build-container-installer:latest
docker run --rm --privileged --volume .:/build-container-installer/build ghcr.io/jasonn3/build-container-installer:latest VERSION=39 IMAGE_NAME=base IMAGE_TAG=39 VARIANT=Server
```

### VSCode Dev Container
Expand Down
17 changes: 16 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ inputs:
description: Enable Anaconda WebUI
required: false
default: "false"
iso_name:
description: Used for specifying the name of the output iso
required: false
enrollment_password:
description: Used for supporting secure boot (requires SECURE_BOOT_KEY_URL to be defined)
required: false
Expand All @@ -44,24 +47,36 @@ inputs:
description: Space delimetered list of additional Lorax templates to include
required: false

outputs:
iso-path:
value: ${{ steps.run_docker.outputs.ISO_PATH }}
description: The location of the .iso object
checksum-path:
value: ${{ steps.run_docker.outputs.CHECKSUM_PATH }}
description: The location of the checksum

runs:
using: composite
steps:
- name: Run docker image
id: run_docker
shell: bash
run: |
# Check if running inside of the action repo
if [[ -z "${{ github.action_ref }}" ]]; then if [[ "${{ github.ref_name }}" =~ (.*)/merge ]]; then tag=pr-${BASH_REMATCH[1]}; else tag=${{ github.ref_name }}; fi; fi
if [[ -z "${tag}" ]]; then tag=${{ github.action_ref }}; fi
docker run --privileged --volume ${{ github.workspace }}:/github/workspace/ ghcr.io/jasonn3/build-container-installer:${tag} \
docker run --privileged --volume ${{ github.workspace }}:/build-container-installer/build ghcr.io/jasonn3/build-container-installer:${tag} \
JasonN3 marked this conversation as resolved.
Show resolved Hide resolved
ARCH=${{ inputs.arch }} \
IMAGE_NAME=${{ inputs.image_name }} \
IMAGE_REPO=${{ inputs.image_repo }} \
VARIANT=${{ inputs.variant }} \
VERSION=${{ inputs.version }} \
IMAGE_TAG=${{ inputs.image_tag || inputs.version }} \
WEB_UI=${{ inputs.web_ui }} \
ISO_NAME=${{ inputs.iso_name }} \
ENROLLMENT_PASSWORD=${{ inputs.enrollment_password }} \
SECURE_BOOT_KEY_URL=${{ inputs.secure_boot_key_url }} \
"ADDITIONAL_TEMPLATES=${{ inputs.additional_templates }}"
echo "ISO_PATH=$(realpath ${{ github.workspace }}/${{ inputs.iso_name }}.iso)" >> $GITHUB_OUTPUT
echo "CHECKSUM_PATH=$(realpath ${{ github.workspace }}/${{ inputs.iso_name }}-CHECKSUM)" >> $GITHUB_OUTPUT

13 changes: 2 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

set -ex

for entry in $@
do
export $entry
for entry in $@; do
JasonN3 marked this conversation as resolved.
Show resolved Hide resolved
export $entry
done

# Pull container
Expand All @@ -15,11 +14,3 @@ make boot.iso $@

# Add container to ISO
make build/deploy.iso $@

# Make output dir in github workspace
mkdir /github/workspace/build || true

# Copy resulting iso to github workspace and fix permissions
cp build/deploy.iso /github/workspace/build
chmod -R ugo=rwX /github/workspace/build

Loading