diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index fd792043f..7588c49e5 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -57,17 +57,24 @@ jobs: echo "run_id=$ID" >> $GITHUB_OUTPUT - name: Download metadata artifact - if: ${{ github.event_name == 'pull_request' }} + if: ${{ github.event_name == 'pull_request' && steps.main.outputs.run_id }} uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: commit run-id: ${{ steps.main.outputs.run_id }} github-token: ${{ secrets.GITHUB_TOKEN }} + # A PR whose base has no `main` run, such as one stacked on another PR's + # branch, has nothing to compare against: it builds from the latest SHA + # from nodejs/node, and `generate` skips the comparison - id: pr if: ${{ github.event_name == 'pull_request' }} run: | - SHA=$(cat commit) + if [ -f commit ]; then + SHA=$(cat commit) + else + SHA=$(git ls-remote https://github.com/nodejs/node.git HEAD | awk '{print $1}') + fi echo "sha=$SHA" >> "$GITHUB_OUTPUT" generate: