From 436c4294a8e7090bdf382148111ef6077319b7ad Mon Sep 17 00:00:00 2001 From: Thomas Brugman Date: Sat, 30 Nov 2024 10:28:23 +0100 Subject: [PATCH] Refactor GitHub Actions workflows to use Docker run action for building Arch Linux ISO and streamline ISO handling process --- .github/workflows/build-check.yaml | 38 ++++--------- .github/workflows/build.yaml | 85 ++++++++---------------------- README.md | 21 ++++++-- 3 files changed, 49 insertions(+), 95 deletions(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index c1c9f256e..14b7e4628 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -16,29 +16,16 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Set up Arch Linux Container - run: | - docker run --privileged --name arch-container -d -v ${{ github.workspace }}:/workdir archlinux:latest sleep infinity - - - name: Build ISO in Arch Container - run: | - docker exec arch-container bash -c " - pacman -Syu --noconfirm && - pacman -S --noconfirm git archiso grub && - cd /workdir && + - name: Build ISO in Arch Linux container + uses: addnab/docker-run-action@v3 + with: + image: archlinux:latest + options: --privileged + run: | + pacman -Syu --noconfirm + pacman -S --noconfirm git archiso grub mkarchiso -v -w workdir/ -o out/ . - " - - - name: Rename ISO to Arch.iso - run: | - docker exec arch-container bash -c " - iso_file=\$(ls /workdir/out/*.iso 2>/dev/null | head -n 1) && - [ -n \"\$iso_file\" ] && mv \$iso_file /workdir/out/Arch.iso || echo 'No ISO file found.' - " - - - name: Copy ISO to Host - run: | - docker cp arch-container:/workdir/out/Arch.iso ${{ github.workspace }}/ || echo 'Failed to copy ISO to host.' + mv out/*.iso out/Arch.iso - name: Get current date id: date @@ -62,7 +49,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/Arch.iso + asset_path: out/Arch.iso asset_name: Arch.iso asset_content_type: application/octet-stream @@ -87,8 +74,3 @@ jobs: -H "Authorization: token $GITHUB_TOKEN" \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/${{ github.repository }}/git/refs/tags/v${{ github.run_id }}-release - - - name: Clean Up - run: | - docker stop arch-container || echo 'Failed to stop the container.' - docker rm arch-container || echo 'Failed to remove the container.' diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index da0d8191a..aaf45518b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -7,72 +7,33 @@ on: jobs: build: - runs-on: ubuntu-latest # Use a standard runner + runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set up Arch Linux Container - run: | - docker run --privileged --name arch-container -d -v ${{ github.workspace }}:/workdir archlinux:latest sleep infinity - - - name: Build ISO in Arch Container - run: | - set -e - docker exec arch-container bash -c " - pacman -Syu --noconfirm && - pacman -S --noconfirm git archiso grub && - cd /workdir && - mkarchiso -v -w workdir/ -o out/ . - " - - - name: Rename ISO to Arch.iso - run: | - set -e - docker exec arch-container bash -c " - iso_file=\$(ls /workdir/out/*.iso 2>/dev/null | head -n 1) && - [ -n \"\$iso_file\" ] && mv \$iso_file /workdir/out/Arch.iso || echo 'No ISO file found.' - " - - - name: List ISO files - run: | - docker exec arch-container bash -c "ls -l /workdir/out/" || echo 'Failed to list files.' - - - name: Copy ISO to Host + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build ISO in Arch Linux container + uses: addnab/docker-run-action@v3 + with: + image: archlinux:latest + options: --privileged run: | - docker cp arch-container:/workdir/out/Arch.iso ${{ github.workspace }}/ || echo 'Failed to copy ISO to host.' + pacman -Syu --noconfirm + pacman -S --noconfirm git archiso grub + mkarchiso -v -w workdir/ -o out/ . + mv out/*.iso out/Arch.iso - name: Get current date - id: date - run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + id: date + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - # Create a release on GitHub using GITHUB_TOKEN - name: Create GitHub Release - id: create_release # Adding an ID to reference the release step - uses: actions/create-release@v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ github.run_id }}-release - release_name: "Arch Linux Release" - body: | - This release contains the Arch Linux ISO built on ${{ steps.date.outputs.date }}. - draft: false - prerelease: false - - # Upload the ISO to the GitHub release with a specific, predictable name - - name: Upload ISO to GitHub Release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ${{ github.workspace }}/Arch.iso - asset_name: Arch.iso - asset_content_type: application/octet-stream - - - name: Clean Up - run: | - docker stop arch-container || echo 'Failed to stop the container.' - docker rm arch-container || echo 'Failed to remove the container.' + uses: softprops/action-gh-release@v1 + with: + files: out/Arch.iso + tag_name: v${{ github.run_id }}-release + release_name: "Arch Linux Release" + body: | + This release contains the Arch Linux ISO built on ${{ steps.date.outputs.date }}. + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index fa1230892..8721393aa 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,22 @@ This repository provides a customized Arch Linux ISO with the system beeps disab ## Features -- **Silent Mode**: The systemd-boot beep and other annoying beeps are completely disabled. -- **Arch Linux Base**: Built on the latest Arch Linux, providing a clean and minimal system. -- **Custom ISO**: Easily build and download a custom ISO with this configuration. -- **Daily Automated Build**: ISO builds are automatically generated and released daily (if using GitHub Actions). - +- **Silent Mode**: Disables systemd-boot and other system beeps for a quieter experience. +- **Arch Linux Base**: Utilizes the latest Arch Linux for a clean and minimal system. +- **Custom ISO**: Provides an easy way to build and download a custom ISO. +- **Automated Daily Builds**: Automatically generates and releases ISO builds daily using GitHub Actions. + +## Table of Contents + +- [Features](#features) +- [How to Build the ISO Locally](#how-to-build-the-iso-locally) + - [Prerequisites](#prerequisites) + - [Steps to Build Locally](#steps-to-build-locally) +- [How to Use GitHub Actions (Automated Workflow)](#how-to-use-github-actions-automated-workflow) + - [How It Works](#how-it-works) + - [GitHub Actions Workflow Overview](#github-actions-workflow-overview) + - [How to Trigger the GitHub Workflow](#how-to-trigger-the-github-workflow) +- [License](#license) --- ## How to Build the ISO Locally