Skip to content

fix(deps): update dependency chalk to v5.4.1 #3

fix(deps): update dependency chalk to v5.4.1

fix(deps): update dependency chalk to v5.4.1 #3

name: Auto-Merge Dependency PRs
on:
pull_request:
types:
- opened
- synchronize
- reopened
- labeled
permissions:
pull-requests: write
contents: write
actions: read
jobs:
process-prs:
runs-on: ubuntu-latest
steps:
# ✅ Step 1: Checkout the repo (Fixes "not a git repository" issue)
- name: Checkout Repository
uses: actions/checkout@v4
# ✅ Step 2: Authenticate GitHub CLI (Ensure gh CLI works)
- name: Authenticate GitHub CLI
run: gh auth setup-git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ✅ Step 3: Fetch all PRs sorted from oldest to newest
- name: Get Oldest PRs
id: get-prs
run: |
prs=$(gh pr list --state open --json number,createdAt --jq 'sort_by(.createdAt) | .[].number')
echo "prs=$prs" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ✅ Step 4: Process PRs One by One
- name: Process PRs
run: |
for pr in $prs; do
echo "Processing PR #$pr"
# Checkout PR branch
gh pr checkout $pr
# Handle conflicts: Ensure latest package.json dependency version is used
git checkout --ours package.json || true
git add package.json || true
# If package.json had conflicts, fix package-lock.json too
if git diff --name-only | grep "package.json"; then
echo "package.json had conflicts, regenerating package-lock.json..."
npm install
git add package-lock.json
fi
# Commit & push resolved conflicts
git commit -m "Resolve dependency conflicts in PR #$pr" || true
git push origin HEAD || true
# Approve PR before merging
gh pr review $pr --approve
# Merge PR when all checks pass
gh pr merge $pr --squash --auto
echo "Merged PR #$pr successfully!"
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}