|
| 1 | +name: Check if ISO can be built |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + schedule: |
| 9 | + - cron: '0 0 * * *' |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout Repository |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 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_ENV |
| 46 | + |
| 47 | + - name: Create GitHub Release |
| 48 | + id: create_release |
| 49 | + |
| 50 | + env: |
| 51 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + 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 |
| 58 | + |
| 59 | + - name: Upload ISO to GitHub Release |
| 60 | + uses: actions/upload-release-asset@v1 |
| 61 | + env: |
| 62 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + 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 |
| 90 | +
|
| 91 | + - name: Clean Up |
| 92 | + run: | |
| 93 | + docker stop arch-container || echo 'Failed to stop the container.' |
| 94 | + docker rm arch-container || echo 'Failed to remove the container.' |
0 commit comments