Added Forgejo workflow

This commit is contained in:
Sohrab Behdani 2025-02-17 00:09:28 +03:30
parent a17d0b7d7f
commit be3dc4eb69
2 changed files with 50 additions and 43 deletions

View file

@ -0,0 +1,50 @@
name: Build and Deploy ISO
on:
release:
types: [published]
jobs:
build_iso:
runs-on: ubuntu-latest
container:
image: archlinux/archlinux:base-devel
privileged: true
env:
Desktop: "plasma"
steps:
- name: Install Node.js
run: pacman -Sy --noconfirm nodejs npm git sudo
- name: Checkout code
uses: actions/checkout@v4
- name: Update system
run: pacman -Syyuu --noconfirm
- name: Check user
run: whoami
- name: Build ISO
run: |
sudo ./build.sh
echo "Renaming the output ISO file"
mv out/*.iso out/ParchLinux-${{ env.Desktop }}-latest.iso
echo "Generating MD5 checksum"
md5sum out/ParchLinux-${{ env.Desktop }}-latest.iso > out/md5sum.txt
echo "Build completed. Files generated:"
ls -lh out/
- name: Setup dependencies
run: pacman -Syu --noconfirm sshpass rsync
- name: Determine remote directory
run: |
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
echo "REMOTE_DIR=/srv/http/beta/${{ env.Desktop }}/" >> $GITHUB_ENV
else
echo "REMOTE_DIR=/srv/http/${{ env.Desktop }}/" >> $GITHUB_ENV
fi
- name: Deploy files
env:
PASS: ${{ secrets.PASS }}
HOST: ${{ secrets.HOST }}
run: |
sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no parch@$HOST "rm -rf $REMOTE_DIR && mkdir -p $REMOTE_DIR"
sshpass -p "$PASS" rsync -avz out/ParchLinux-${{ env.Desktop }}-latest.iso out/md5sum.txt parch@$HOST:$REMOTE_DIR

View file

@ -1,43 +0,0 @@
stages:
- build
- deploy
image: archlinux/archlinux:base-devel
variables:
Desktop: "plasma"
build_iso:
stage: build
script:
- ./build.sh
- echo "Renaming the output ISO file"
- mv out/*.iso out/ParchLinux-$Desktop-latest.iso
- echo "Generating MD5 checksum"
- md5sum out/ParchLinux-$Desktop-latest.iso > out/md5sum.txt
- echo "Build completed. Files generated:"
- ls -lh out/
artifacts:
paths:
- out/ParchLinux-$Desktop-latest.iso
- out/md5sum.txt
rules:
- if: $CI_COMMIT_TAG
deploy_iso:
stage: deploy
dependencies:
- build_iso
script:
- echo "Installing sshpass and rsync"
- pacman -Syu --noconfirm sshpass rsync
- echo "Determining the remote directory based on the tag"
- if [[ "$CI_COMMIT_TAG" == *"beta"* ]]; then export REMOTE_DIR="/srv/http/beta/$Desktop/"; else export REMOTE_DIR="/srv/http/$Desktop/"; fi
- echo "Removing old ISO files from remote directory"
- sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no parch@$SSH_ROOT rm -rf "$REMOTE_DIR/"
- echo "Creating new directory on remote host"
- sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no parch@$SSH_ROOT mkdir -p "$REMOTE_DIR/"
- echo "Uploading new ISO via rsync"
- sshpass -p "$PASS" rsync -r out/ParchLinux-$Desktop-latest.iso out/md5sum.txt parch@$SSH_ROOT:"$REMOTE_DIR/"
rules:
- if: $CI_COMMIT_TAG