diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index fdf0dcac1..a742b2636 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -119,11 +119,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v6 with: - depth: 1 + fetch-depth: 1 - id: head-version name: Determine Node version for HEAD run: | + if [[ ! -f ".nvmrc" ]]; then + echo "::error::Cannot find .nvmrc in the HEAD commit." + exit 1 + fi + NODE_VERSION=$(cat .nvmrc) echo "NODE_VERSION: ${NODE_VERSION}" echo "node_version=${NODE_VERSION}" >> $GITHUB_OUTPUT @@ -133,12 +138,17 @@ jobs: uses: actions/checkout@v6 with: ref: ${{ env.BASE_REF }} - depth: 1 + fetch-depth: 1 - name: 'Backport: Verify Node versions unchanged' env: HEAD_VERSION: ${{ steps.head-version.outputs.node_version }} run: | + if [[ ! -f ".nvmrc" ]]; then + echo "::error::Cannot find .nvmrc in the base commit." + exit 1 + fi + BASE_VERSION=$(cat .nvmrc) echo "HEAD_VERSION: ${HEAD_VERSION}" echo "BASE_VERSION: ${BASE_VERSION}" diff --git a/build.mjs b/build.mjs index 410ac3d52..e6a17ae5c 100644 --- a/build.mjs +++ b/build.mjs @@ -83,7 +83,7 @@ const checkNodeVersionsPlugin = { } // Write the node version to `.nvmrc`. - writeFile( + await writeFile( join(__dirname, ".nvmrc"), nodeVersion.substring("node".length) + "\n", "utf-8",