Skip to content

Commit cf52d5b

Browse files
Refactor GitHub Actions workflow to use docker-run-action for building Arch Linux ISO and streamline artifact handling
1 parent ca9aea5 commit cf52d5b

File tree

1 file changed

+18
-71
lines changed

1 file changed

+18
-71
lines changed

.github/workflows/build-check.yaml

Lines changed: 18 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -16,79 +16,26 @@ jobs:
1616
- name: Checkout Repository
1717
uses: actions/checkout@v4
1818

19-
- name: Set up Arch Linux Container
20-
run: |
21-
docker run --privileged --name arch-container -d -v ${{ github.workspace }}:/workdir archlinux:latest sleep infinity
22-
23-
- name: Build ISO in Arch Container
24-
run: |
25-
docker exec arch-container bash -c "
26-
pacman -Syu --noconfirm &&
27-
pacman -S --noconfirm git archiso grub &&
28-
cd /workdir &&
29-
mkarchiso -v -w workdir/ -o out/ .
30-
"
31-
32-
- name: Rename ISO to Arch.iso
33-
run: |
34-
docker exec arch-container bash -c "
35-
iso_file=\$(ls /workdir/out/*.iso 2>/dev/null | head -n 1) &&
36-
[ -n \"\$iso_file\" ] && mv \$iso_file /workdir/out/Arch.iso || echo 'No ISO file found.'
37-
"
38-
39-
- name: Copy ISO to Host
40-
run: |
41-
docker cp arch-container:/workdir/out/Arch.iso ${{ github.workspace }}/ || echo 'Failed to copy ISO to host.'
42-
43-
- name: Get current date
44-
id: date
45-
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
46-
47-
- name: Create GitHub Release
48-
id: create_release
49-
uses: actions/[email protected]
50-
env:
51-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Build ISO in Arch Linux Container
20+
uses: addnab/docker-run-action@v3
5221
with:
53-
tag_name: v${{ github.run_id }}-release
54-
release_name: "Arch Linux Release"
55-
body: "Arch Linux ISO built on ${{ steps.date.outputs.date }}"
56-
draft: false
57-
prerelease: false
22+
image: archlinux:latest
23+
options: >
24+
--privileged
25+
--workdir /workdir
26+
-v ${{ github.workspace }}:/workdir
27+
run: |
28+
pacman -Syu --noconfirm
29+
pacman -S --noconfirm git archiso grub
30+
mkarchiso -v -w workdir/ -o out/ .
5831
59-
- name: Upload ISO to GitHub Release
60-
uses: actions/upload-release-asset@v1
61-
env:
62-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
- name: Upload ISO Artifact
33+
uses: actions/upload-artifact@v3
6334
with:
64-
upload_url: ${{ steps.create_release.outputs.upload_url }}
65-
asset_path: ${{ github.workspace }}/Arch.iso
66-
asset_name: Arch.iso
67-
asset_content_type: application/octet-stream
68-
69-
- name: Delete GitHub Release
70-
env:
71-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72-
run: |
73-
release_id=$(curl -s \
74-
-H "Authorization: token $GITHUB_TOKEN" \
75-
-H "Accept: application/vnd.github.v3+json" \
76-
https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ github.run_id }}-release | jq -r .id) &&
77-
curl -X DELETE \
78-
-H "Authorization: token $GITHUB_TOKEN" \
79-
-H "Accept: application/vnd.github.v3+json" \
80-
https://api.github.com/repos/${{ github.repository }}/releases/$release_id
81-
82-
- name: Delete Git Tag
83-
env:
84-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85-
run: |
86-
curl -X DELETE \
87-
-H "Authorization: token $GITHUB_TOKEN" \
88-
-H "Accept: application/vnd.github.v3+json" \
89-
https://api.github.com/repos/${{ github.repository }}/git/refs/tags/v${{ github.run_id }}-release
35+
name: Arch.iso
36+
path: out/Arch.iso
9037

91-
- name: Clean Up
38+
- name: Delete ISO Artifact
39+
if: always()
9240
run: |
93-
docker stop arch-container || echo 'Failed to stop the container.'
94-
docker rm arch-container || echo 'Failed to remove the container.'
41+
rm -f out/Arch.iso

0 commit comments

Comments
 (0)