Update Node.js and npm Packages #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Node.js and npm Packages | |
on: | |
schedule: | |
- cron: '0 0 */1 * *' | |
workflow_dispatch: | |
jobs: | |
update-packages: | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Repository auschecken | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# 2. Node.js und Yarn einrichten | |
- name: Set up Node.js and Yarn | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'yarn' | |
# 3. npm-check-updates installieren | |
- name: Install npm-check-updates (ncu) | |
run: npm install -g npm-check-updates | |
# 4. Aktualisiere die package.json | |
- name: Update package.json dependencies | |
run: ncu -u | |
# 5. Installiere die aktualisierten Pakete und aktualisiere yarn.lock | |
- name: Install updated dependencies | |
run: yarn install | |
# 6. Änderungen committen und pushen | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
if git diff-index --quiet HEAD --; then | |
echo "No changes to commit"; | |
else | |
git commit -m "chore: upgrade dependencies (package.json and yarn.lock)" | |
git push --force "https://${TOKEN}@github.com/${{ github.repository }}.git" | |
fi |