forked from NationalBankBelgium/stark
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (143 loc) · 6.13 KB
/
bump-angular-deps.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# 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