diff --git a/.github/actions/diff-js-api-changes/action.yml b/.github/actions/diff-js-api-changes/action.yml index 9e186d27cc0..54d7e51180a 100644 --- a/.github/actions/diff-js-api-changes/action.yml +++ b/.github/actions/diff-js-api-changes/action.yml @@ -3,22 +3,28 @@ description: Check for breaking changes in the public React Native JS API runs: using: composite steps: - - name: Compute merge base with main + - name: Fetch PR and main, compute merge base id: merge_base shell: bash + env: + PR_SHA: ${{ github.event.pull_request.head.sha }} run: | git fetch origin main - git fetch --deepen=500 - echo "merge_base=$(git merge-base HEAD origin/main)" >> $GITHUB_OUTPUT + git fetch origin "$PR_SHA" --depth=500 + echo "merge_base=$(git merge-base "$PR_SHA" origin/main)" >> $GITHUB_OUTPUT - - name: Output snapshot before state for comparison + - name: Extract before and after API snapshots shell: bash env: SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-changes + MERGE_BASE: ${{ steps.merge_base.outputs.merge_base }} + PR_SHA: ${{ github.event.pull_request.head.sha }} run: | mkdir -p $SCRATCH_DIR - git show ${{ steps.merge_base.outputs.merge_base }}:packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-before.d.ts \ + git show "$MERGE_BASE":packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-before.d.ts \ || echo "" > $SCRATCH_DIR/ReactNativeApi-before.d.ts + git show "$PR_SHA":packages/react-native/ReactNativeApi.d.ts > $SCRATCH_DIR/ReactNativeApi-after.d.ts \ + || echo "" > $SCRATCH_DIR/ReactNativeApi-after.d.ts - name: Run breaking change detection shell: bash @@ -27,5 +33,5 @@ runs: run: | node ./scripts/js-api/diff-api-snapshot \ $SCRATCH_DIR/ReactNativeApi-before.d.ts \ - ./packages/react-native/ReactNativeApi.d.ts \ + $SCRATCH_DIR/ReactNativeApi-after.d.ts \ > $SCRATCH_DIR/output.json diff --git a/.github/workflows/danger-pr.yml b/.github/workflows/danger-pr.yml index ce41f6f602c..25b4d53f4fd 100644 --- a/.github/workflows/danger-pr.yml +++ b/.github/workflows/danger-pr.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest if: github.repository == 'facebook/react-native' steps: - - name: Check out PR branch + - name: Check out main branch uses: actions/checkout@v6 - name: Setup Node.js uses: ./.github/actions/setup-node