wf test
This commit is contained in:
@@ -22,6 +22,12 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
run: |
|
||||
# Clean up any previous runs to avoid "destination path already exists" errors
|
||||
if [ -d "/tmp/nixpkgs" ]; then
|
||||
echo "Cleaning up existing /tmp/nixpkgs directory..."
|
||||
rm -rf /tmp/nixpkgs
|
||||
fi
|
||||
|
||||
# Disable terminal prompts for all git operations
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
export GIT_ASKPASS="/bin/echo"
|
||||
@@ -33,10 +39,11 @@ jobs:
|
||||
|
||||
cd /tmp/nixpkgs
|
||||
|
||||
# Configure git author/committer
|
||||
git config --global user.name "${{ env.GIT_AUTHOR_NAME }}"
|
||||
git config --global user.email "${{ env.GIT_AUTHOR_EMAIL }}"
|
||||
git config --global init.defaultBranch master
|
||||
# Configure git author/committer (local to this repo)
|
||||
# Removing --global to avoid polluting the runner's user config
|
||||
git config user.name "${{ env.GIT_AUTHOR_NAME }}"
|
||||
git config user.email "${{ env.GIT_AUTHOR_EMAIL }}"
|
||||
git config init.defaultBranch master
|
||||
|
||||
# Verify checkout
|
||||
git status
|
||||
@@ -45,8 +52,13 @@ jobs:
|
||||
- name: Check for available packages to update
|
||||
id: check-packages
|
||||
run: |
|
||||
cd /tmp/nixpkgs
|
||||
echo "Found packages in pkgs/ directory:"
|
||||
ls -1 pkgs/ | grep -v default.nix | grep -v AGENTS.md || echo "No package directories found"
|
||||
if [ -d "pkgs" ]; then
|
||||
find pkgs -mindepth 1 -maxdepth 1 -type d -not -name default.nix | grep -v AGENTS.md || echo "No packages found"
|
||||
else
|
||||
echo "pkgs directory not found"
|
||||
fi
|
||||
|
||||
# Check if flake.nix exists
|
||||
if [ -f "flake.nix" ]; then
|
||||
@@ -60,6 +72,7 @@ jobs:
|
||||
- name: Update packages
|
||||
id: update
|
||||
run: |
|
||||
cd /tmp/nixpkgs
|
||||
set -e
|
||||
|
||||
# Create timestamp for branch naming
|
||||
@@ -92,7 +105,11 @@ jobs:
|
||||
echo "Checking all packages for updates..."
|
||||
|
||||
# Get list of package directories (exclude default.nix and AGENTS.md)
|
||||
PACKAGES=$(find pkgs -mindepth 1 -maxdepth 1 -type d -not -name default.nix -not -name AGENTS.md -exec basename {} \; 2>/dev/null | sort)
|
||||
if [ -d "pkgs" ]; then
|
||||
PACKAGES=$(find pkgs -mindepth 1 -maxdepth 1 -type d -not -name default.nix -not -name AGENTS.md -exec basename {} \; 2>/dev/null | sort)
|
||||
else
|
||||
PACKAGES=""
|
||||
fi
|
||||
|
||||
if [ -z "$PACKAGES" ]; then
|
||||
echo "No packages found to update"
|
||||
@@ -153,6 +170,7 @@ jobs:
|
||||
- name: Verify packages build
|
||||
if: steps.update.outputs.has_updates == 'true'
|
||||
run: |
|
||||
cd /tmp/nixpkgs
|
||||
PACKAGES="${{ steps.update.outputs.updated_packages }}"
|
||||
echo "Verifying builds for: $PACKAGES"
|
||||
|
||||
@@ -171,6 +189,7 @@ jobs:
|
||||
- name: Push branch and create pull request
|
||||
if: steps.update.outputs.has_updates == 'true'
|
||||
run: |
|
||||
cd /tmp/nixpkgs
|
||||
BRANCH="${{ steps.update.outputs.branch_name }}"
|
||||
PACKAGES="${{ steps.update.outputs.updated_packages }}"
|
||||
|
||||
@@ -181,19 +200,27 @@ jobs:
|
||||
|
||||
echo "Creating pull request..."
|
||||
|
||||
# Create pull request using tea CLI
|
||||
wget -q https://dl.gitea.com/tea/latest/tea-linux-amd64 -O /tmp/tea
|
||||
chmod +x /tmp/tea
|
||||
# Ensure tea is available (using host package)
|
||||
if ! command -v tea &> /dev/null; then
|
||||
echo "Error: tea not found in PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Authenticate tea if needed
|
||||
if ! tea login list | grep -q "code.m3ta.dev"; then
|
||||
echo "Adding tea login..."
|
||||
tea login add --name m3ta --url https://code.m3ta.dev --token "${{ secrets.NIX_UPDATE_TOKEN }}"
|
||||
fi
|
||||
|
||||
# Get commit messages for PR description
|
||||
COMMITS=$(git log origin/master..origin/"${BRANCH}" --pretty=format:"%h %s" | sed 's/^/- /')
|
||||
|
||||
# Create PR
|
||||
/tmp/tea pr create \
|
||||
tea pr create \
|
||||
--head "${BRANCH}" \
|
||||
--base master \
|
||||
--title "chore: update packages with nix-update" \
|
||||
--body "Automated package updates using nix-update.\n\nUpdated packages:\n${PACKAGES}\n\nCommits:\n${COMMITS}" \
|
||||
--body "$(printf "Automated package updates using nix-update.\n\nUpdated packages:\n%s\n\nCommits:\n%s" "$PACKAGES" "$COMMITS")" \
|
||||
--assignees m3tam3re \
|
||||
--labels automated-update || echo "Failed to create PR. Please create manually."
|
||||
|
||||
|
||||
Reference in New Issue
Block a user