name: Hyprland Stack Update Check on: schedule: - cron: '0 6 * * 1,4' workflow_dispatch: jobs: check-update: runs-on: iso-builder steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.FORGEJO_TOKEN }} - name: Check for existing open PR id: prcheck run: | set -euo pipefail OPEN_PRS=$(curl -fsSL \ -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ "https://git.rp1.hu/api/v1/repos/${{ github.repository }}/pulls?state=open&limit=50") EXISTS=$(echo "$OPEN_PRS" | python3 -c " import sys, json pulls = json.load(sys.stdin) found = any(p.get('head', {}).get('ref', '').startswith('update/hyprland-stack') for p in pulls) print('yes' if found else 'no') ") echo "EXISTS=$EXISTS" >> $GITHUB_OUTPUT echo "Open PR exists: $EXISTS" - name: Check upstream versions id: check if: steps.prcheck.outputs.EXISTS == 'no' run: | set -euo pipefail sudo pacman -S --needed --noconfirm pacman-contrib curl jq UPDATED_PKGS=() SUMMARY="" PKGS=( hyprutils hyprlang hyprwayland-scanner aquamarine hyprcursor hyprgraphics hyprwire hyprland-guiutils hyprland xdg-desktop-portal-hyprland hyprpolkitagent hyprland-qt-support dms-shell ) for pkg in "${PKGS[@]}"; do dir="hyprland-raveos/$pkg" [ -d "$dir" ] || continue LOCAL_VER=$(grep '^pkgver=' "$dir/PKGBUILD" | head -1 | cut -d= -f2 | tr -d "'\"") UPSTREAM_PKGBUILD=$(curl -fsSL --retry 3 "https://gitlab.archlinux.org/archlinux/packaging/packages/${pkg}/-/raw/main/PKGBUILD" 2>/dev/null || true) [ -n "$UPSTREAM_PKGBUILD" ] || continue UPSTREAM_VER=$(echo "$UPSTREAM_PKGBUILD" | grep '^pkgver=' | head -1 | cut -d= -f2 | tr -d "'\"") [ -n "$UPSTREAM_VER" ] || continue if [ "$LOCAL_VER" != "$UPSTREAM_VER" ]; then echo "Update available for $pkg: $LOCAL_VER -> $UPSTREAM_VER" # Frissites letoltese es pkgrel beallitasa echo "$UPSTREAM_PKGBUILD" > "$dir/PKGBUILD" sed -i 's/^pkgrel=[0-9]*/pkgrel=10/' "$dir/PKGBUILD" if [ "$pkg" = "hyprpolkitagent" ] || [ "$pkg" = "hyprland-qt-support" ]; then sed -i 's/^pkgrel=10/pkgrel=20/' "$dir/PKGBUILD" fi UPDATED_PKGS+=("$pkg") SUMMARY="${SUMMARY}\n- **${pkg}**: \`${LOCAL_VER}\` -> \`${UPSTREAM_VER}-10\`" else echo "$pkg is up-to-date ($LOCAL_VER)" fi done if [ ${#UPDATED_PKGS[@]} -gt 0 ]; then echo "HAS_UPDATES=yes" >> $GITHUB_OUTPUT echo "COUNT=${#UPDATED_PKGS[@]}" >> $GITHUB_OUTPUT echo -e "SUMMARY<> $GITHUB_OUTPUT else echo "HAS_UPDATES=no" >> $GITHUB_OUTPUT echo "No updates found for hyprland stack." fi - name: Create branch and open single Pull Request if: steps.prcheck.outputs.EXISTS == 'no' && steps.check.outputs.HAS_UPDATES == 'yes' run: | set -euo pipefail DATE=$(date +%Y%m%d-%H%M) BRANCH="update/hyprland-stack-${DATE}" git config user.name "RaveOS Bot" git config user.email "bot@raveos.hu" git checkout -b "$BRANCH" git add hyprland-raveos/ git commit -m "update: hyprland stack (${{ steps.check.outputs.COUNT }} packages)" git remote set-url origin "https://bot:${{ secrets.FORGEJO_TOKEN }}@git.rp1.hu/RaveOS/RaveOS-PKGBUILD.git" git push origin "$BRANCH" PR_BODY="Automata Hyprland stack frissítés (${{ steps.check.outputs.COUNT }} csomag):\n${{ steps.check.outputs.SUMMARY }}\n\nA csomagok a merge után az \`iso-builder\` runneren sorrendben fordulnak le, GPG aláírással kerülnek a RaveOS repóba." curl -fsSL -X POST \ -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" \ -H "Content-Type: application/json" \ "https://git.rp1.hu/api/v1/repos/${{ github.repository }}/pulls" \ -d "$(jq -n \ --arg title "Hyprland stack frissítés (${{ steps.check.outputs.COUNT }} csomag)" \ --arg head "$BRANCH" \ --arg base "main" \ --arg body "$PR_BODY" \ '{title: $title, head: $head, base: $base, body: $body}')" echo "Single PR successfully opened for hyprland stack update."