@@ -20,21 +20,30 @@ jobs:
2020 secrets : inherit
2121
2222 lint :
23- name : Lint
24- runs-on : macos-latest
25-
26- steps :
27- - uses : actions/checkout@v4
28-
29- - run : |
30- swift format lint --strict --recursive .
31-
32- - name : Suggest fixes (if check fails)
33- if : failure()
34- run : |
35- echo "### Here's how to fix the formatting locally:" >> $GITHUB_STEP_SUMMARY
36- echo "" >> $GITHUB_STEP_SUMMARY
37- echo '```bash' >> $GITHUB_STEP_SUMMARY
38- echo "# Format all Swift files" >> $GITHUB_STEP_SUMMARY
39- echo 'swift format -i --recursive .' >> $GITHUB_STEP_SUMMARY
40- echo '```' >> $GITHUB_STEP_SUMMARY
23+ name : Lint
24+ runs-on : macos-latest
25+
26+ steps :
27+ - name : Checkout PR merge ref if called from PR
28+ if : ${{ github.event.pull_request.number }}
29+ uses : actions/checkout@v4
30+ with :
31+ ref : refs/pull/${{ github.event.pull_request.number }}/merge
32+ fetch-depth : 0
33+
34+ - name : Checkout fallback
35+ if : ${{ !github.event.pull_request.number }}
36+ uses : actions/checkout@v4
37+
38+ - run : |
39+ swift format lint --strict --recursive .
40+
41+ - name : Suggest fixes (if check fails)
42+ if : failure()
43+ run : |
44+ echo "### Here's how to fix the formatting locally:" >> $GITHUB_STEP_SUMMARY
45+ echo "" >> $GITHUB_STEP_SUMMARY
46+ echo '```bash' >> $GITHUB_STEP_SUMMARY
47+ echo "# Format all Swift files" >> $GITHUB_STEP_SUMMARY
48+ echo 'swift format -i --recursive .' >> $GITHUB_STEP_SUMMARY
49+ echo '```' >> $GITHUB_STEP_SUMMARY
0 commit comments