Skip to content

Commit 5244769

Browse files
committed
Update upgrade-dependencies workflow
1 parent b3ab999 commit 5244769

File tree

3 files changed

+10
-73
lines changed

3 files changed

+10
-73
lines changed

.github/workflows/test-and-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
node: ["18", "20"]
20+
node: ["lts/*", latest]
2121
fail-fast: true
2222
steps:
2323
- uses: actions/checkout@main
2424
- uses: actions/setup-node@main
2525
with:
2626
node-version: ${{ matrix.node }}
27+
check-latest: true
2728
- name: Cache node modules
2829
uses: actions/cache@main
2930
env:
Lines changed: 8 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,21 @@
1-
name: upgrade-dependencies
1+
name: upgrade-node-dependencies
22

33
on:
44
workflow_dispatch: {}
55
schedule:
66
- cron: "0 0 * * *"
77

88
jobs:
9-
upgrade-deps:
9+
upgrade-node-dependencies:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@main
1313
- uses: actions/setup-node@main
1414
with:
15-
node-version: 20
16-
- name: Cache node modules
17-
uses: actions/cache@main
18-
env:
19-
cache-name: cache-node-${{ matrix.node }}-modules
15+
node-version: "lts/*"
16+
check-latest: true
17+
- uses: fardjad/my-actions/npm-automatic-dependency-update@main
2018
with:
21-
path: ~/.npm
22-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
23-
restore-keys: |
24-
${{ runner.os }}-build-${{ env.cache-name }}-
25-
${{ runner.os }}-build-
26-
${{ runner.os }}-
27-
- name: Setup Git
28-
run: |
29-
git config --local user.name "github-actions[bot]"
30-
git config --local user.email "github-actions[bot]@users.noreply.github.com"
31-
git config --local pull.rebase true
32-
33-
# work around "insufficient permission for adding an object to repository database .git/object" issue
34-
sudo chmod -R ugo+rwX .git
35-
- name: Check for updates
36-
id: check-updates
37-
run: |
38-
set -ex
39-
npm ci &> /dev/null
40-
npx ncu
41-
npm i &> /dev/null
42-
npm audit fix --quiet --no-progress --no-fund || true
43-
npm run fix &> /dev/null || true
44-
45-
git add -u
46-
git update-index --refresh
47-
if ! git diff-index --quiet HEAD --; then
48-
echo "is-changed=1" >> $GITHUB_OUTPUT
49-
fi
50-
- name: Create a PR
51-
if: steps.check-updates.outputs.is-changed
52-
id: create-pr
53-
run: |
54-
npm version patch
55-
PKG_VERSION="$(node -e 'process.stdout.write(require("./package.json").version)')"
56-
57-
REMOTE_REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
58-
CURRENT_BRANCH="$(git branch --show-current)"
59-
NEW_BRANCH="v${PKG_VERSION}"
60-
61-
if git ls-remote --exit-code --heads "${REMOTE_REPO}" "${NEW_BRANCH}" > /dev/null; then
62-
# PR already exists
63-
exit 0
64-
fi
65-
66-
git commit -a -m "${PKG_VERSION}" --no-verify
67-
git pull "${REMOTE_REPO}" "${CURRENT_BRANCH}"
68-
git checkout -b "${NEW_BRANCH}"
69-
git push "${REMOTE_REPO}" "HEAD:${NEW_BRANCH}"
70-
71-
PR_URL=$(gh pr create -B "${CURRENT_BRANCH}" -H "${NEW_BRANCH}" -f)
72-
echo "pr-url=${PR_URL}" >> $GITHUB_OUTPUT
73-
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
- name: Approve and merge the PR
76-
if: steps.create-pr.outputs.pr-url
77-
run: |
78-
gh pr review --approve "${PR_URL}"
79-
gh pr merge --auto --delete-branch --rebase "${PR_URL}"
80-
env:
81-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
82-
PR_URL: ${{ steps.create-pr.outputs.pr-url }}
19+
github-token: ${{ secrets.GH_PAT }}
20+
ncu-check-extra-flags: --dep prod
21+
ncu-upgrade-extra-flags: --dep prod

.ncurc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)