@@ -17,19 +17,47 @@ jobs:
1717 if : ${{ github.actor != 'OSBotify' || github.event_name == 'workflow_call' }}
1818 runs-on : ubuntu-latest
1919 steps :
20+ - name : Count commits between merge base and HEAD
21+ id : count
22+ run : |
23+ # Compare the base commit and HEAD to get the count of commits after base
24+ # up to and including HEAD. Add 2 to this total when fetching history.
25+ #
26+ # When opening a PR, GitHub will create a merge commit that squashes
27+ # your changes for use in the workflow. So your history locally
28+ # may look like
29+ # o---o---o---B - development
30+ # /
31+ # ---o---1---C---o---o---A - main
32+ # Note that the `1` is the merge-base of development and main. The
33+ # number of commits after `1` upto and including `A` is 4.
34+ # In the workflow, GitHub squashs development, so it becomes:
35+ # ---o---1---C---o---o---A - main
36+ # \--M - PR branch
37+ # Where `M`` is the new squashed commit. To fetch enough history to
38+ # include the merge base, we need to fetch `M`, `A` through `C` and
39+ # `1` for total of 4+2=6 commits. The +2 commits accounts for the
40+ # base `1` and merge commit `M`.
41+ RAW_COUNT="$(gh api "repos/$REPO/compare/${BASE}...main" | jq -r '.total_commits')"
42+ ADJUSTED_COUNT=$((RAW_COUNT + 2))
43+ echo "count=$ADJUSTED_COUNT" >> "$GITHUB_OUTPUT"
44+ env :
45+ GH_TOKEN : ${{ github.token }}
46+ BASE : ${{ github.event.pull_request.base.sha }}
47+ REPO : ${{ github.repository }}
48+
2049 - name : Checkout
2150 # v4
2251 uses : actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
52+ with :
53+ fetch-depth : ${{ fromJSON(steps.count.outputs.count) }}
2354
2455 - name : Setup Node
2556 uses : ./.github/actions/composite/setupNode
2657 with :
2758 IS_DESKTOP_BUILD : true
28-
59+
2960 - name : Run ESLint to check for deprecation warnings
3061 run : |
31- # This will just fetch the latest commit from main
32- git fetch origin main --no-tags --depth=1
33-
3462 # shellcheck disable=SC2046
3563 npm run lint-changed
0 commit comments