-
Notifications
You must be signed in to change notification settings - Fork 181
/
weekly-lockfile-maintenance.sh
executable file
·28 lines (19 loc) · 948 Bytes
/
weekly-lockfile-maintenance.sh
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
#!/bin/bash
# Question: Why does this script exist? Why not use dependabot?
# Answer: https://11sigma.com/blog/2021/09/03/yarn-lock-how-it-works-and-what-you-risk-without-maintaining-yarn-dependencies-deep-dive/
# https://stackoverflow.com/questions/3822621/how-to-exit-if-a-command-failed/19469570#19469570
set -e
set -o pipefail
# https://circleci.com/docs/2.0/using-shell-scripts/#set-error-flags
set -o nounset
set -o errexit
git checkout main
git pull --ff-only
BRANCH_NAME=feat/lockfile-maintenance-ci-job-$(date +"%m-%d-%Y")
git checkout -b "$BRANCH_NAME"
yarn upgrade
git add yarn.lock
git commit -m "chore: weekly lockfile maintenance"
git push --set-upstream origin "$BRANCH_NAME"
BODY='{"head":''"'${BRANCH_NAME}'"'',"base":"main","title":"Weekly lockfile maintenance"}'
curl -X POST -H "Accept:application/vnd.github.v3+json" -u "$GIT_AUTHOR_NAME":"$GH_TOKEN" https://api.github.com/repos/stoplightio/elements/pulls -d "$BODY"