Refactor GitHub Actions workflows to use Docker run action for building Arch Linux ISO and streamline ISO handling process #15
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check if ISO can be built | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Build ISO in Arch Linux container | |
| uses: addnab/docker-run-action@v3 | |
| with: | |
| image: archlinux:latest | |
| options: --privileged | |
| run: | | |
| pacman -Syu --noconfirm | |
| pacman -S --noconfirm git archiso grub | |
| mkarchiso -v -w workdir/ -o out/ . | |
| mv out/*.iso out/Arch.iso | |
| - name: Get current date | |
| id: date | |
| run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/[email protected] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| 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 | |
| - 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: out/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 |