Bump angular dependencies #66
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
# Based on https://github.com/dependabot/dependabot-core/issues/1296#issuecomment-657438154 | |
name: Bump angular dependencies | |
on: | |
schedule: | |
- cron: "0 0 * * 1" | |
workflow_dispatch: | |
env: | |
TZ: "Europe/Brussels" | |
NPM_VERSION: "10.1.0" | |
LOGS_DIR: /tmp/stark/logs | |
LOGS_FILE: /tmp/stark/logs/build-perf.log | |
jobs: | |
bump-angular-deps: | |
runs-on: ubuntu-latest | |
env: | |
UPDATED_DEPS: 0 | |
steps: | |
# See: https://github.com/marketplace/actions/setup-node-js-environment | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
# See: https://github.com/marketplace/actions/cache | |
# See doc: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules-${{ matrix.node_version }}-${{ matrix.os }} | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install npm ${{ env.NPM_VERSION }} | |
run: npm i -g npm@${{ env.NPM_VERSION }} | |
- name: List main variables | |
run: | | |
echo "Commit SHA : ${GITHUB_SHA}" | |
echo "Reference : ${GITHUB_REF}" | |
echo "Head branch : ${GH_HEAD_REF}" | |
echo "Base branch : ${GITHUB_BASE_REF}" | |
echo "Build number: ${GITHUB_RUN_NUMBER}" | |
echo "Repository : ${GITHUB_REPOSITORY}" | |
echo "Event : ${GITHUB_EVENT_NAME}" | |
echo "Author : ${GITHUB_ACTOR}" | |
echo "PR Number : ${GH_PR_NUMBER}" | |
# See: https://github.com/marketplace/actions/checkout | |
- uses: actions/checkout@v4 | |
- name: Configure git user info | |
run: | | |
git config --local user.name "NBB Bot" | |
git config --local user.email "[email protected]" | |
- name: "Upgrade '@angular/*' deps thanks to 'npm-check-updates'" | |
run: | | |
npx npm-check-updates -t minor -u "/^@angular\/.*$/" | |
npm i | |
if [[ -n $(git status --porcelain) ]]; | |
then | |
echo "UPDATED_DEPS=1" >> $GITHUB_ENV | |
git add package.json package-lock.json | |
git commit -m "chore(deps-dev): bump \`@angular/*\` dependencies" --no-verify | |
npm run sync:packages-dependencies | |
fi | |
- name: "Upgrade '@angular-devkit/*' deps thanks to 'npm-check-updates'" | |
run: | | |
npx npm-check-updates -t minor -u "/^@angular-devkit\/.*$/" | |
npm i | |
if [[ -n $(git status --porcelain) ]]; | |
then | |
echo "UPDATED_DEPS=1" >> $GITHUB_ENV | |
git add package.json package-lock.json | |
git commit -m "chore(deps-dev): bump \`@angular-devkit/*\` dependencies" --no-verify | |
npm run sync:packages-dependencies | |
fi | |
- name: "Upgrade '@angular-builders/*' deps thanks to 'npm-check-updates'" | |
run: | | |
npx npm-check-updates -t minor -u "/^@angular-builders\/.*$/" | |
npm i | |
if [[ -n $(git status --porcelain) ]]; | |
then | |
echo "UPDATED_DEPS=1" >> $GITHUB_ENV | |
git add package.json package-lock.json | |
git commit -m "chore(deps-dev): bump \`@angular-builders/*\` dependencies" --no-verify | |
npm run sync:packages-dependencies | |
fi | |
- name: "Upgrade '@angular/*' deps thanks to 'npm-check-updates' in ./starter" | |
run: | | |
npx npm-check-updates -t minor -u "/^@angular\/.*$/" --packageFile ./starter/package.json | |
if [[ -n $(git status --porcelain) ]]; | |
then | |
echo "UPDATED_DEPS=1" >> $GITHUB_ENV | |
git add starter/package.json | |
git commit -m "chore(deps): bump \`@angular/*\` dependencies in ./starter" --no-verify | |
fi | |
- name: Create file & folder for GitHub Actions logs | |
run: | | |
# cfr scripts/_ghactions-group.sh | |
mkdir -p ${{ env.LOGS_DIR }} | |
touch ${{ env.LOGS_FILE }} | |
- name: "Upgrade '@angular/*' deps thanks to 'npm-check-updates' or update package-lock.json file in ./showcase" | |
run: | | |
npx npm-check-updates -t minor -u "/^@angular\/.*$/" --packageFile ./showcase/package.json | |
SHOWCASE_UPDATED_DEPS=0 | |
if [[ -n $(git status --porcelain) ]]; | |
then | |
SHOWCASE_UPDATED_DEPS=1 | |
fi | |
echo "SHOWCASE_UPDATED_DEPS: $SHOWCASE_UPDATED_DEPS" | |
npm run build | |
git checkout starter/package.json | |
npm run clean:modules:showcase | |
cd showcase | |
npm install --package-lock-only --ignore-scripts | |
git add package-lock.json | |
if [[ SHOWCASE_UPDATED_DEPS -eq 1 ]]; | |
then | |
git add package.json | |
git commit -m "chore(deps): bump \`@angular/*\` dependencies in showcase" --no-verify | |
echo "UPDATED_DEPS=1" >> $GITHUB_ENV | |
else | |
git commit -m 'chore(showcase): update "package-lock.json" file' --no-verify | |
fi | |
- name: Set PR branch name based on current date | |
if: env.UPDATED_DEPS == 1 | |
run: | | |
PR_BRANCH_NAME="nbb-bot/deps/angular-$( date +%Y%m%d )" | |
echo "PR_BRANCH_NAME=${PR_BRANCH_NAME}" >> $GITHUB_ENV | |
# See: https://github.com/marketplace/actions/create-pull-request | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
if: env.UPDATED_DEPS == 1 | |
with: | |
token: ${{ secrets.NBBBOT_TOKEN }} | |
branch: ${{ env.PR_BRANCH_NAME }} | |
author: NBB Bot <[email protected]> | |
committer: NBB Bot <[email protected]> | |
title: "scheduled: bump `@angular/*`, `@angular-devkit/*` and `@angular-builders/*` dependencies" | |
body: | | |
Automated changes by @nbb-bot. Upgrade `@angular/*`, `@angular-devkit/*` and `@angular-builders/*` dependencies. | |
labels: dependencies |