diff --git a/.github/workflows/package-size-comment.yml b/.github/workflows/package-size-comment.yml index c03a956b..80b84fd4 100644 --- a/.github/workflows/package-size-comment.yml +++ b/.github/workflows/package-size-comment.yml @@ -70,6 +70,11 @@ jobs: && pullRequest.base.repo.full_name === expectedBaseRepository, ) + if (matches.length === 0) { + core.info('The pull request closed or its head changed. Skipping the size comment.') + return + } + if (matches.length !== 1) { core.setFailed(`Expected one open pull request for ${run.head_sha}, found ${matches.length}`) return @@ -78,6 +83,7 @@ jobs: core.setOutput('number', matches[0].number) - name: Download package size report + if: steps.pull-request.outputs.number != '' uses: actions/download-artifact@v8 with: name: package-size-report @@ -88,6 +94,7 @@ jobs: # The artifact comes from a workflow run that may be a fork pull request. # Treat it as untrusted input and check it before it becomes a comment. - name: Validate package size report + if: steps.pull-request.outputs.number != '' env: COMMENT_PATH: ${{ runner.temp }}/package-size-comment.md EXPECTED_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} @@ -140,6 +147,7 @@ jobs: sed 's/@/@/g' "$report" > "$COMMENT_PATH" - name: Post comment on pull request + if: steps.pull-request.outputs.number != '' uses: actions/github-script@v9 env: COMMENT_PATH: ${{ runner.temp }}/package-size-comment.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3ce59041..d980af96 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,14 @@ jobs: - name: Plan release id: plan - run: node scripts/prepare-release.ts + run: | + # CI started before this workflow existed can finish after its merge. + if [ "$GITHUB_EVENT_NAME" = 'workflow_run' ] && [ ! -f scripts/prepare-release.ts ]; then + echo 'Skip CI for a commit that predates release automation.' + echo 'release=false' >> "$GITHUB_OUTPUT" + else + node scripts/prepare-release.ts + fi release: needs: prepare diff --git a/scripts/check-release-channel.ts b/scripts/check-release-channel.ts index b222882b..1a9e70a3 100644 --- a/scripts/check-release-channel.ts +++ b/scripts/check-release-channel.ts @@ -10,7 +10,7 @@ if (!distTag || !output) const names = ['@nuxt/scripts', '@nuxt/scripts-cli', '@nuxt/scripts-devtools'] const currentVersions = await Promise.all(names.map(async (name) => { const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(name)}`, { - headers: { accept: 'application/vnd.npm.install-v1+json', 'cache-control': 'no-cache' }, + headers: { 'accept': 'application/vnd.npm.install-v1+json', 'cache-control': 'no-cache' }, signal: AbortSignal.timeout(30000), }) if (!response.ok)