wf test
This commit is contained in:
@@ -2,7 +2,7 @@ name: Update Nix Packages with nix-update
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 2 * * *"
|
||||
- cron: "0 2,14 * * *" # Every 12 hours at 2 AM and 2 PM
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
package:
|
||||
@@ -10,6 +10,10 @@ on:
|
||||
required: false
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: nix-update-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
GIT_AUTHOR_NAME: "nix-update bot"
|
||||
GIT_AUTHOR_EMAIL: "bot@m3ta.dev"
|
||||
@@ -60,60 +64,39 @@ jobs:
|
||||
cd "$REPO_DIR"
|
||||
set -e
|
||||
|
||||
# Ensure we are on master
|
||||
git checkout master
|
||||
|
||||
UPDATES_FOUND=false
|
||||
UPDATED_PACKAGES=""
|
||||
|
||||
IGNORE_PACKAGES=(
|
||||
"hyprpaper-random"
|
||||
"launch-webapp"
|
||||
"stt-ptt"
|
||||
"tuxedo-backlight"
|
||||
"zellij-ps"
|
||||
"msty-studio"
|
||||
"rofi-project-opener"
|
||||
"pomodoro-timer"
|
||||
)
|
||||
|
||||
check_commit() {
|
||||
[ "$1" != "$(git rev-parse HEAD)" ] && echo "true" || echo "false"
|
||||
}
|
||||
|
||||
has_update_script() {
|
||||
local pkg=$1
|
||||
nix eval --raw ".#$pkg.passthru.updateScript" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
run_update() {
|
||||
local pkg=$1
|
||||
local before_hash=$(git rev-parse HEAD)
|
||||
|
||||
# IGNORE CHECKS
|
||||
for ignore in "${IGNORE_PACKAGES[@]}"; do
|
||||
if [ "$pkg" = "$ignore" ]; then
|
||||
echo "ℹ️ Skipping $pkg (in ignore list)"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Base args: Flake mode, Commit changes, Use GitHub Releases API
|
||||
# --use-github-releases ensures we only get "Latest Release" (ignoring pre-releases/random tags)
|
||||
local args=("--flake" "--commit" "--use-github-releases")
|
||||
|
||||
# Special configuration
|
||||
if [ "$pkg" = "opencode" ]; then
|
||||
echo "ℹ️ Config for opencode: --subpackage node_modules"
|
||||
args+=("--subpackage" "node_modules")
|
||||
if ! has_update_script "$pkg"; then
|
||||
echo "⏭️ Skipping $pkg (no updateScript defined)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
args+=("$pkg")
|
||||
|
||||
echo "Checking $pkg..."
|
||||
# We allow failure (exit 0) so one package doesn't crash the whole loop
|
||||
if nix-update "${args[@]}" 2>&1 | tee /tmp/update-${pkg}.log; then
|
||||
echo "::group::Updating $pkg"
|
||||
if nix-update --flake --commit --use-update-script "$pkg" 2>&1 | tee /tmp/update-${pkg}.log; then
|
||||
if [ "$(check_commit "$before_hash")" = "true" ]; then
|
||||
echo "✓ Updated $pkg"
|
||||
echo "✅ Updated $pkg"
|
||||
echo "::endgroup::"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "::endgroup::"
|
||||
|
||||
if ! grep -q "already up to date\|No new version found" /tmp/update-${pkg}.log; then
|
||||
echo "⚠️ Update failed for $pkg"
|
||||
fi
|
||||
@@ -128,11 +111,11 @@ jobs:
|
||||
UPDATED_PACKAGES="$pkg"
|
||||
fi
|
||||
else
|
||||
echo "✗ Package 'pkgs/$pkg' not found"
|
||||
echo "❌ Package 'pkgs/$pkg' not found"
|
||||
fi
|
||||
else
|
||||
PACKAGES=$(find pkgs -mindepth 1 -maxdepth 1 -type d -not -name default.nix -not -name AGENTS.md -exec basename {} \; 2>/dev/null | sort)
|
||||
|
||||
PACKAGES=$(find pkgs -mindepth 1 -maxdepth 1 -type d -exec basename {} \; 2>/dev/null | sort)
|
||||
|
||||
if [ -z "$PACKAGES" ]; then
|
||||
echo "No packages found to update"
|
||||
exit 0
|
||||
@@ -148,9 +131,9 @@ jobs:
|
||||
|
||||
UPDATED_PACKAGES=$(echo "$UPDATED_PACKAGES" | sed 's/^, //')
|
||||
COMMIT_COUNT=$(git rev-list --count origin/master..HEAD)
|
||||
|
||||
|
||||
if [ "$COMMIT_COUNT" -gt 0 ]; then
|
||||
echo "✓ $COMMIT_COUNT updates committed locally."
|
||||
echo "✅ $COMMIT_COUNT updates committed locally."
|
||||
echo "has_updates=true" >> $GITHUB_OUTPUT
|
||||
echo "updated_packages=${UPDATED_PACKAGES}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
@@ -191,10 +174,12 @@ jobs:
|
||||
|
||||
echo "✓ Successfully pushed updates for: $PACKAGES"
|
||||
|
||||
- name: Cleanup Credentials
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: |
|
||||
rm -f ~/.git-credentials
|
||||
rm -rf "$REPO_DIR"
|
||||
rm -f /tmp/update-*.log
|
||||
|
||||
- name: Summary
|
||||
if: always()
|
||||
|
||||
Reference in New Issue
Block a user