From cf52d5ba3e95a9e2069dc578e35420391d247782 Mon Sep 17 00:00:00 2001 From: Thomas Brugman Date: Wed, 4 Dec 2024 18:00:21 +0100 Subject: [PATCH 1/2] Refactor GitHub Actions workflow to use docker-run-action for building Arch Linux ISO and streamline artifact handling --- .github/workflows/build-check.yaml | 89 ++++++------------------------ 1 file changed, 18 insertions(+), 71 deletions(-) diff --git a/.github/workflows/build-check.yaml b/.github/workflows/build-check.yaml index c1c9f256e..506d8f127 100644 --- a/.github/workflows/build-check.yaml +++ b/.github/workflows/build-check.yaml @@ -16,79 +16,26 @@ 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 && - 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.' - - - name: Get current date - id: date - run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT - - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build ISO in Arch Linux Container + uses: addnab/docker-run-action@v3 with: - tag_name: v${{ github.run_id }}-release - release_name: "Arch Linux Release" - body: "Arch Linux ISO built on ${{ steps.date.outputs.date }}" - draft: false - prerelease: false + image: archlinux:latest + options: > + --privileged + --workdir /workdir + -v ${{ github.workspace }}:/workdir + run: | + pacman -Syu --noconfirm + pacman -S --noconfirm git archiso grub + mkarchiso -v -w workdir/ -o out/ . - - name: Upload ISO to GitHub Release - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload ISO Artifact + uses: actions/upload-artifact@v3 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: Delete GitHub Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - release_id=$(curl -s \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ github.run_id }}-release | jq -r .id) && - curl -X DELETE \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/releases/$release_id - - - name: Delete Git Tag - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - curl -X DELETE \ - -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: Arch.iso + path: out/Arch.iso - - name: Clean Up + - name: Delete ISO Artifact + if: always() run: | - docker stop arch-container || echo 'Failed to stop the container.' - docker rm arch-container || echo 'Failed to remove the container.' + rm -f out/Arch.iso From 00b7c53030a3af389f3f98771bbc9026cc2d9f79 Mon Sep 17 00:00:00 2001 From: Thomas Brugman Date: Wed, 4 Dec 2024 18:00:46 +0100 Subject: [PATCH 2/2] Refactor GitHub Actions workflow to use docker-run-action for building Arch Linux ISO and simplify container management --- .github/workflows/build.yaml | 69 +++++++++--------------------------- 1 file changed, 17 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index da0d8191a..db926378a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,66 +13,31 @@ 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: | - set -e - 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 + --workdir /workdir + -v ${{ github.workspace }}:/workdir + run: | + pacman -Syu --noconfirm + pacman -S --noconfirm git archiso grub 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 - run: | - docker cp arch-container:/workdir/out/Arch.iso ${{ github.workspace }}/ || echo 'Failed to copy ISO to host.' - name: Get current date 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 }} + uses: ncipollo/release-action@v1 with: - tag_name: v${{ github.run_id }}-release - release_name: "Arch Linux Release" + token: ${{ secrets.GITHUB_TOKEN }} + tag: v${{ github.run_id }}-release + name: "Arch Linux Release" body: | This release contains the Arch Linux ISO built on ${{ steps.date.outputs.date }}. + artifacts: out/Arch.iso 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.' + prerelease: false \ No newline at end of file