Skip to content

Commit 85bf59d

Browse files
committed
Fix upgrade-dependencies workflow
1 parent 60326a2 commit 85bf59d

2 files changed

Lines changed: 23 additions & 20 deletions

File tree

.github/workflows/upgrade-dependencies.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,33 @@ jobs:
2424
${{ runner.os }}-build-${{ env.cache-name }}-
2525
${{ runner.os }}-build-
2626
${{ runner.os }}-
27-
- name: Create a PR
28-
id: upgrade-dependencies
27+
- name: Setup Git
2928
run: |
30-
set -e
31-
3229
git config --local user.name "github-actions[bot]"
3330
git config --local user.email "github-actions[bot]@users.noreply.github.com"
3431
git config --local pull.rebase true
3532
36-
npm ci --quiet --no-progress
37-
npx ncu
38-
npm i --quiet --no-progress
39-
npm audit fix --quiet --no-progress || true
40-
npm run fix || true
41-
42-
if git diff-index --quiet HEAD --; then
43-
# no changes
44-
exit 0
45-
fi
46-
4733
# work around "insufficient permission for adding an object to repository database .git/object" issue
4834
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
4944
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: |
5054
npm version patch
5155
PKG_VERSION="$(node -e 'process.stdout.write(require("./package.json").version)')"
5256
@@ -65,14 +69,14 @@ jobs:
6569
git push "${REMOTE_REPO}" "HEAD:${NEW_BRANCH}"
6670
6771
PR_URL=$(gh pr create -B "${CURRENT_BRANCH}" -H "${NEW_BRANCH}" -f)
68-
echo "PR_URL=${PR_URL}" >> $GITHUB_OUTPUT
72+
echo "pr-url=${PR_URL}" >> $GITHUB_OUTPUT
6973
env:
7074
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7175
- name: Approve and merge the PR
76+
if: steps.create-pr.outputs.pr-url
7277
run: |
73-
set -e
7478
gh pr review --approve "${PR_URL}"
7579
gh pr merge --auto --delete-branch --rebase "${PR_URL}"
7680
env:
7781
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
78-
PR_URL: ${{ steps.upgrade-dependencies.outputs.PR_URL }}
82+
PR_URL: ${{ steps.create-pr.outputs.pr-url }}

.ncurc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
2-
"upgrade": true,
3-
"silent": true
2+
"upgrade": true
43
}

0 commit comments

Comments
 (0)