-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (88 loc) · 4.44 KB
/
rpi-aarch64-image-builder.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Archlinux aarch64 Raspberry Pi Image Builder
on: [push]
jobs:
build-image:
name: Build Archlinux aarch64 Raspberry Pi Image
env:
LOOP_IMAGE: archlinux-aarch64-rpi.img
LOOP_IMAGE_SIZE: 4G
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
RPI_MODEL: 5
ARM_VERSION: aarch64
ARCH_AARCH64_IMG_URL: http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-${{ env.ARM_VERSION }}-latest.tar.gz
ARCH_AARCH64_IMG_URL_MD5: http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-${ARM_VERSION}-latest.tar.gz.md5
runs-on: self-hosted
environment: main
# container: archlinux:latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Generate Dynamic Variables
run: |
echo "RPI_HOSTNAME=sz-arch-${{ env.ARM_VERSION }}-rpi${{ env.RPI_MODEL }}" >> $GITHUB_ENV
echo "WORKDIR_BASE=/mnt/github-actions/${{ github.repository }}/branches/${{ github.ref_name }}/${{ github.run_id }}/${ARM_VERSION}/rpi${RPI_MODEL}" >> $GITHUB_ENV
echo "LOOP_IMAGE_PATH=${WORKDIR_BASE}/sz-arch-${ARM_VERSION}-rpi${RPI_MODEL}.img" >> $GITHUB_ENV
echo "DISTRO=$(cat /etc/*-release | grep ^ID= | cut -d'=' -f2)" >> $GITHUB_ENV
- name: Display All Environment Variables
run: |
printenv
# - name: Update system and install dependencies for Arch Linux
# if: env.DISTRO == 'arch'
# run: |
# sudo pacman -Syu --noconfirm
# sudo pacman -S --noconfirm qemu-user-static-binfmt qemu-user-static dosfstools wget libarchive sudo arch-install-scripts
# - name: Update system and install dependencies for Ubuntu
# if: env.DISTRO == 'ubuntu'
# run: |
# sudo apt update
# sudo apt-get install -y arch-install-scripts qemu-user-static binfmt-support dosfstools wget libarchive-tools sudo
# - name: Create Work Folder and apply permissions
# run: |
# sudo mkdir -p $WORKDIR_BASE
# sudo chown -R $USER:$USER $WORKDIR_BASE
# echo "Created $WORKDIR_BASE and applied permissions"
# - name: Create Image File
# run: |
# fallocate -l $LOOP_IMAGE_SIZE $LOOP_IMAGE_PATH
# - name: Setup Loop Device
# run: |
# sudo losetup -fP $LOOP_IMAGE_PATH
# LOOP_DEVICE=$(sudo losetup -j $LOOP_IMAGE_PATH | cut -d: -f1)
# echo "Loop device is $LOOP_DEVICE"
# echo "LOOP_DEVICE=$LOOP_DEVICE" >> $GITHUB_ENV
# - name: Run Build Script
# run: |
# sudo chmod +x ./build-archlinux-rpi-aarch64-img.sh
# sudo ./build-archlinux-rpi-aarch64-img.sh $LOOP_DEVICE $RPI_MODEL $ARM_VERSION $WORKDIR_BASE $RPI_HOSTNAME
# - name: Upload Image and Get URL
# if: success()
# run: |
# ISO_URL=$(curl --upload-file $LOOP_IMAGE_PATH https://pub.strat.zone/)
# echo "ISO_URL=$ISO_URL" >> $GITHUB_ENV
# - name: Notify Success
# if: success()
# run: |
# SUCCESS_MESSAGE="🎉 Awesome! The Raspberry Pi image build succeeded 🚀\nAuthor: ${{ github.actor }}\nBranch: ${{ github.ref }}\nCommit Message: ${{ github.event.head_commit.message }}\n[View Last Commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) 📜\nThe custom-built Archlinux image for Raspberry Pi Model ${{ env.RPI_MODEL }} with ${{ env.ARM_VERSION }} architecture is now available for download:\n[Download Image]($ISO_URL) 📦\nFilename: archlinux-${{ env.ARM_VERSION }}-rpi-${{ env.RPI_MODEL }}.img"
# curl -X POST -H "Content-Type: application/json" -d "{\"content\": \"$SUCCESS_MESSAGE\"}" $DISCORD_WEBHOOK_URL
# - name: Notify Failure
# if: failure()
# run: |
# FAILURE_MESSAGE="😞 Oops! The pipeline for **${{ github.repository }}** has failed.\n[Check the logs and troubleshoot here.](https://github.com/${{ github.repository }}/commit/${{ github.sha }}) 🛠️"
# curl -X POST -H "Content-Type: application/json" -d "{\"content\": \"$FAILURE_MESSAGE\"}" $DISCORD_WEBHOOK_URL
# - name: Umount Loop Device
# if: always()
# run: |
# sudo umount -R $WORKDIR_BASE || true
# echo "Unmounted $WORKDIR_BASE"
# - name: Delete Work Folder
# if: always()
# run: |
# sudo rm -rf $WORKDIR_BASE
# echo "Work folder deleted"
# - name: Release Loop Device
# if: always()
# run: |
# if [ -n "$LOOP_DEVICE" ]; then
# sudo losetup -d $LOOP_DEVICE
# echo "Loop device $LOOP_DEVICE released"
# fi