Skip to content

Commit f34cadb

Browse files
committed
Update check-node-version to compare .nvmrc
1 parent dda23c7 commit f34cadb

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

.github/workflows/pr-checks.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,42 +105,41 @@ jobs:
105105
run: npx tsx --test
106106

107107
check-node-version:
108-
if: github.triggering_actor != 'dependabot[bot]'
109-
name: Check Action Node versions
108+
if: github.triggering_actor != 'dependabot[bot]' && startsWith(github.head_ref, 'backport-')
109+
name: Check Action Node versions for Backport
110110
runs-on: ubuntu-latest
111-
timeout-minutes: 45
111+
timeout-minutes: 5
112112
env:
113113
BASE_REF: ${{ github.base_ref }}
114114

115115
permissions:
116116
contents: read
117117

118118
steps:
119-
- uses: actions/checkout@v6
119+
- name: Checkout repository
120+
uses: actions/checkout@v6
121+
with:
122+
depth: 1
123+
120124
- id: head-version
121-
name: Verify all Actions use the same Node version
125+
name: Determine Node version for HEAD
122126
run: |
123-
NODE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
127+
NODE_VERSION=$(cat .nvmrc)
124128
echo "NODE_VERSION: ${NODE_VERSION}"
125-
if [[ $(echo "$NODE_VERSION" | wc -l) -gt 1 ]]; then
126-
echo "::error::More than one node version used in 'action.yml' files."
127-
exit 1
128-
fi
129129
echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
130130
131131
- id: checkout-base
132132
name: 'Backport: Check out base ref'
133-
if: ${{ startsWith(github.head_ref, 'backport-') }}
134133
uses: actions/checkout@v6
135134
with:
136135
ref: ${{ env.BASE_REF }}
136+
depth: 1
137137

138138
- name: 'Backport: Verify Node versions unchanged'
139-
if: steps.checkout-base.outcome == 'success'
140139
env:
141140
HEAD_VERSION: ${{ steps.head-version.outputs.node_version }}
142141
run: |
143-
BASE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
142+
BASE_VERSION=$(cat .nvmrc)
144143
echo "HEAD_VERSION: ${HEAD_VERSION}"
145144
echo "BASE_VERSION: ${BASE_VERSION}"
146145
if [[ "$BASE_VERSION" != "$HEAD_VERSION" ]]; then

0 commit comments

Comments
 (0)