Skip to content

Delete .github/workflows/ncudepsweb.yaml #77

Delete .github/workflows/ncudepsweb.yaml

Delete .github/workflows/ncudepsweb.yaml #77

Workflow file for this run

name: Update Dependencies
on:
schedule:
- cron: '0 12 */2 * *' # Runs every other day at 12:00 UTC
workflow_dispatch:
push:
branches:
- main
jobs:
update-dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js (LTS)
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install npm-check-updates
run: npm install -g npm-check-updates pnpm
- name: Run npm-check-updates and Extract Updated Packages
id: run-ncu
run: |
ncu -w * > ncu.log
cat ncu.log
# Extract updated packages and their new versions
UPDATED_PACKAGES=$(grep -E '^\s*[^ ]+\s+\S+\s+→\s+\S+' ncu.log | sed 's/^ *//' | awk '{gsub("@", "", $1); print $1 " " $4}' | tr '\n' ', ' | sed 's/, $//')
echo "UPDATED_PACKAGES=$UPDATED_PACKAGES" >> $GITHUB_ENV
- name: Install updated dependencies
id: install-dependencies
run: |
pnpm install > npm-install.log 2>&1
INSTALL_EXIT_CODE=$?
# Check for peer dependency conflicts
if grep -q "Could not resolve dependency" npm-install.log; then
echo "PEER_CONFLICT=true" >> $GITHUB_ENV
grep -A 5 "peer dep missing" npm-install.log > peer-conflicts.log
fi
# Check for general install failure
if [ $INSTALL_EXIT_CODE -ne 0 ]; then
echo "INSTALL_FAILED=true" >> $GITHUB_ENV
fi
continue-on-error: true
- name: Check for changes and Commit
if: env.INSTALL_FAILED != 'true' && env.PEER_CONFLICT != 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json
if git diff --cached --quiet; then
echo "No changes to commit."
exit 0
else
COMMIT_MESSAGE="deps: ${{ env.UPDATED_PACKAGES }}"
echo "Committing with message: $COMMIT_MESSAGE"
git commit -m "$COMMIT_MESSAGE"
git push
fi
- name: Create GitHub Issue for npm install issues
if: env.INSTALL_FAILED == 'true' || env.PEER_CONFLICT == 'true'
run: |
if [ "${{ env.INSTALL_FAILED }}" = "true" ]; then
TITLE="Dependency Update Failed: npm install error"
BODY_HEADER="## Dependency Update Failed\n\nThe automated dependency update process encountered an error during the npm install step."
else
TITLE="Dependency Update: Peer Dependency Conflicts Detected"
BODY_HEADER="## Peer Dependency Conflicts Detected\n\nThe automated dependency update process detected peer dependency conflicts."
fi
ISSUE_BODY="${BODY_HEADER}
### npm-check-updates logs:
\`\`\`
$(cat ncu.log)
\`\`\`
### npm install logs:
\`\`\`
$(cat npm-install.log)
\`\`\`
"
if [ -f peer-conflicts.log ]; then
ISSUE_BODY="${ISSUE_BODY}
### Specific peer conflicts:
\`\`\`
$(cat peer-conflicts.log)
\`\`\`
"
fi
ISSUE_BODY="${ISSUE_BODY}
Please review the logs and take appropriate action to resolve the issue."
gh issue create --repo ${{ github.repository }} --title "$TITLE" --body "$ISSUE_BODY"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}