@@ -114,3 +114,44 @@ jobs:
114114 # we won't be able to find them on Windows.
115115 npm config set script-shell bash
116116 npm test
117+
118+ check-node-version :
119+ if : ${{ github.event.pull_request }}
120+ name : Check node version consistency
121+ runs-on : ubuntu-latest
122+ timeout-minutes : 45
123+ env :
124+ BASE_REF : ${{ github.base_ref }}
125+
126+ steps :
127+ - uses : actions/checkout@v4
128+ - id : head-version
129+ name : check HEAD node version
130+ run : |
131+ NODE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
132+ echo "NODE_VERSION: ${NODE_VERSION}"
133+ if [[ $(echo "$NODE_VERSION" | wc -l) -gt 1 ]]; then
134+ echo "Error: More than one node version used in actions."
135+ exit 1
136+ fi
137+ echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT
138+
139+ - id : checkout-base
140+ name : check out base ref for backport check
141+ if : ${{ startsWith(github.head_ref, 'backport-') }}
142+ uses : actions/checkout@v4
143+ with :
144+ ref : ${{ env.BASE_REF }}
145+
146+ - name : compare with node version on base ref for backport check
147+ if : steps.checkout-base.outcome == 'success'
148+ env :
149+ HEAD_VERSION : ${{ steps.head-version.outputs.node_version }}
150+ run : |
151+ BASE_VERSION=$(find . -name "action.yml" -exec yq -e '.runs.using' {} \; | grep node | sort | uniq)
152+ echo "HEAD_VERSION: ${HEAD_VERSION}"
153+ echo "BASE_VERSION: ${BASE_VERSION}"
154+ if [[ "$BASE_VERSION" != "$HEAD_VERSION" ]]; then
155+ echo "Error: Cannot change node version in a backport PR."
156+ exit 1
157+ fi
0 commit comments