1- name : Build Arch Linux  ISO 
1+ name : Build and Save  ISO 
22
33on :
44  schedule :
5-     - cron : ' 0 0 * * *' #  Run the workflow every day at midnight
6-   workflow_dispatch :      #  Manual trigger option
5+     - cron : ' 0 0 * * *' #  Run daily at midnight UTC
6+   workflow_dispatch :
7+   workflow_run :
8+     workflows : ["Create/Update Release", "Update Packages"] 
9+     types :
10+       - completed 
11+ 
12+ env :
13+   ISO_FILENAME : archlinux-custom.iso 
14+   MAX_RETRIES : 3 
15+   RETRY_DELAY : 30 
716
817jobs :
9-   build :
18+   build-iso  :
1019    runs-on : ubuntu-latest 
11-     container :
12-       image :  archlinux:latest 
13-      
20+     permissions :
21+       contents :  write 
22+ 
1423    steps :
15-       - name : Checkout code  
16-         uses : actions/checkout@v3  
24+       - name : Checkout Repository  
25+         uses : actions/checkout@v4  
1726
18-       - name : Install dependencies 
27+       - name : Set up environment variables 
28+         id : env 
1929        run : | 
20-           pacman -Syu --noconfirm 
21-           pacman -S --noconfirm archiso git 
22-            
30+           echo "VERSION=$(date +'%Y.%m.%d')" >> $GITHUB_ENV 
31+           echo "BUILD_ID=$(date +'%Y%m%d_%H%M%S')" >> $GITHUB_ENV 
32+           echo "WORKSPACE=${GITHUB_WORKSPACE}" >> $GITHUB_ENV 
33+ 
34+ name : Set up Docker 
35+         run : | 
36+           docker build -t arch-iso-builder . 
37+ 
2338name : Build ISO 
2439        run : | 
25-           mkdir -p work out 
26-           cp -r /usr/share/archiso/configs/releng/* work/ 
27-           cp -r * work/airootfs/ || true  
28-           mkarchiso -v -w work/ -o out/ work/ 
40+           mkdir -p workdir out 
41+            
42+           # Build ISO with retry logic 
43+           for i in $(seq 1 ${{ env.MAX_RETRIES }}); do 
44+             if docker run --rm --privileged \ 
45+               -v ${{ env.WORKSPACE }}:/workdir \ 
46+               arch-iso-builder \ 
47+               bash -c "mkarchiso -v -w /workdir/work/ -o /workdir/out/ /workdir/"; then 
48+               echo "ISO build successful" 
49+               break 
50+             fi 
51+              
52+             if [ $i -eq ${{ env.MAX_RETRIES }} ]; then 
53+               echo "Failed to build ISO after ${{ env.MAX_RETRIES }} attempts" 
54+               exit 1 
55+             fi 
56+              
57+             echo "Attempt $i failed. Retrying in ${{ env.RETRY_DELAY }} seconds..." 
58+             sleep ${{ env.RETRY_DELAY }} 
59+           done 
2960
30- name : Upload ISO 
61+ name : Generate ISO Checksum 
62+         run : | 
63+           cd out 
64+           sha256sum ${{ env.ISO_FILENAME }} > ${{ env.ISO_FILENAME }}.sha256 
65+           cat ${{ env.ISO_FILENAME }}.sha256 
66+ 
67+ name : Update Release with ISO 
68+         env :
69+           GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
70+         run : | 
71+           # Check if release exists 
72+           if ! gh release view "${{ env.VERSION }}" &>/dev/null; then 
73+             # Create release if it doesn't exist 
74+             gh release create "${{ env.VERSION }}" \ 
75+               --title "Release ${{ env.VERSION }}" \ 
76+               --notes "Arch Linux Custom ISO Build ${{ env.VERSION }}" 
77+           fi 
78+            
79+           # Upload ISO and checksum to the release 
80+           gh release upload "${{ env.VERSION }}" \ 
81+             "out/${{ env.ISO_FILENAME }}" \ 
82+             "out/${{ env.ISO_FILENAME }}.sha256" \ 
83+             --clobber 
84+ 
85+ name : Update Release Notes 
86+         env :
87+           GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
88+         run : | 
89+           # Generate ISO information 
90+           { 
91+             echo "## 💿 ISO Information" 
92+             echo "- Filename: \`${{ env.ISO_FILENAME }}\`" 
93+             echo "- Size: \`$(ls -lh out/${{ env.ISO_FILENAME }} | awk '{print $5}')\`" 
94+             echo "- SHA256: \`$(cat out/${{ env.ISO_FILENAME }}.sha256 | awk '{print $1}')\`" 
95+             echo "- Build ID: \`${{ env.BUILD_ID }}\`" 
96+             echo "- Build Date: \`$(date -u '+%Y-%m-%d %H:%M:%S UTC')\`" 
97+           } > iso_info.md 
98+            
99+           # Append ISO information to existing release notes 
100+           gh release edit "${{ env.VERSION }}" \ 
101+             --notes-file <(cat <(gh release view "${{ env.VERSION }}" --json body --jq .body) iso_info.md) 
102+ 
103+ name : Upload Build Artifacts 
104+         if : always() 
31105        uses : actions/upload-artifact@v3 
32106        with :
33-           name : arch-linux-iso 
34-           path : out/*.iso 
35-           retention-days : 5 
107+           name : iso-build-${{ env.BUILD_ID }} 
108+           path : | 
109+             out/${{ env.ISO_FILENAME }} 
110+             out/${{ env.ISO_FILENAME }}.sha256 
111+ retention-days : 7 
112+ 
113+       - name : Clean Up 
114+         if : always() 
115+         run : | 
116+           rm -rf workdir out 
117+ 
118+ name : Notify on Failure 
119+         if : failure() 
120+         uses : actions/github-script@v6 
121+         with :
122+           script : | 
123+             const issue = await github.rest.issues.create({ 
124+               owner: context.repo.owner, 
125+               repo: context.repo.repo, 
126+               title: '❌ ISO Build Failed', 
127+               body: `The ISO build workflow failed on ${new Date().toISOString()}\n\nBuild ID: ${process.env.BUILD_ID}\n\nPlease check the workflow logs for details.` 
128+             }); 
0 commit comments