Skip to content

Update build.yml to optimize Workflow. #70

Update build.yml to optimize Workflow.

Update build.yml to optimize Workflow. #70

Workflow file for this run

name: Build ISO
on:
pull_request:
branches:
- main
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Run the workflow every day at midnight
jobs:
build:
runs-on: ubuntu-latest # Use a standard runner
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: pacman-cache
key: ${{ runner.os }}-pacman-cache
- name: Set up Arch Linux Container
run: |
docker run --privileged --name arch-container -d \
-v ${{ github.workspace }}:/workdir \
-v pacman-cache:/var/cache/pacman/pkg \
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
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/[email protected]
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: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/Arch.iso
tag_name: v${{ github.run_id }}-release
name: "Arch Linux Release"
body: |
This release contains the Arch Linux ISO built on ${{ steps.date.outputs.date }}.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean Up
run: |
docker stop arch-container || echo 'Failed to stop the container.'
docker rm arch-container || echo 'Failed to remove the container.'