Skip to content

Build Images

Build Images #46

Workflow file for this run

name: Build Images
on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted, arch]
steps:
- name: Checkout Images
uses: actions/checkout@v4
with:
path: images
- name: Install dependencies
run: |
sudo pacman -Sy --noconfirm --needed \
python parted btrfs-progs \
git wget arch-install-scripts perl \
unzip gptfdisk dosfstools multipath-tools jq
yay -S --noconfirm --needed pod2man
yay -S --noconfirm --needed \
mmdebstrap debian-archive-keyring arch-test-bin
wget https://deb-mirror.fydeos.com/pacman/repo/fyde/aarch64/python-imageforge-1.1.0-2-any.pkg.tar.zst
sudo pacman -U --noconfirm python-imageforge-1.1.0-2-any.pkg.tar.zst
- name: Build Image
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf /var/lib/pacman/db.lck ./out ./work ./work-deb
for i in {1..3}; do
sudo python ./images/fydetab-arch/profiledef -c ./images/fydetab-arch/ -w ./work -o ./out && break
done
for i in {1..3}; do
sudo python ./images/fydetab-debian/profiledef -c ./images/fydetab-debian/ -w ./work-deb -o ./out && break
done
- name: Cleanup
if: always()
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf ./work ./work-deb
- name: Set current date as tag name
id: set_tag_name
run: echo "TAG_NAME=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Upload images
env:
HOST: ${{ secrets.HOST }}
KEY: ${{ secrets.KEY }}
run: |
# Save key to temp file
echo "$KEY" > /tmp/key
chmod 600 /tmp/key
for i in $(ls ./out/Debian*.img.xz); do
echo "Uploading $i"
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /tmp/key $i $HOST:/home/fydeadmin/download.fydeos.io/fydetabduo/other_os/
done
for i in $(ls ./out/Arch*.img.xz); do
echo "Uploading $i"
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /tmp/key $i $HOST:/home/fydeadmin/download.fydeos.io/fydetabduo/other_os/
done
rm /tmp/key
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
TAG_NAME: ${{ env.TAG_NAME }}
id: create_release
run: |
RELEASE_BODY=""
for i in $(ls ./out/Debian*.img.xz); do
FILENAME=$(basename $i)
URL="https://download.fydeos.io/fydetabduo/other_os/debian/$FILENAME"
SHA256=$(sha256sum $i | awk '{ print $1 }')
RELEASE_BODY+="\n$FILENAME: $URL\nsha256 for $FILENAME:\n\`\`\`\n$SHA256\n\`\`\`\n"
done
for i in $(ls ./out/Arch*.img.xz); do
FILENAME=$(basename $i)
URL="https://download.fydeos.io/fydetabduo/other_os/arch/$FILENAME"
SHA256=$(sha256sum $i | awk '{ print $1 }')
RELEASE_BODY+="\n$FILENAME: $URL\nsha256 for $FILENAME:\n\`\`\`\n$SHA256\n\`\`\`\n"
done
RELEASE_RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\", \"body\": \"$RELEASE_BODY\", \"draft\": false, \"prerelease\": false}" \
"https://api.github.com/repos/$REPO/releases")
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r '.id')
if [ "$RELEASE_ID" == "null" ]; then
echo "Failed to create a release. Response: $RELEASE_RESPONSE"
exit 1
fi
- name: Clean up
run: |
rm ./out/ -rf