Skip to content

Commit 65586ec

Browse files
authored
Update detect-api-changes.yml
1 parent 169c043 commit 65586ec

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

.github/workflows/detect-api-changes.yml

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Select latest Xcode
2626
uses: maxim-lobanov/setup-xcode@v1
2727
with:
28-
xcode-version: '15.4'
28+
xcode-version: '16.1'
2929

3030
- name: 🚚 Fetch repo
3131
uses: actions/checkout@v4
@@ -54,11 +54,35 @@ jobs:
5454
target: '${{ github.event.inputs.old || github.event.pull_request.base.ref }}'
5555
githubRepo: '${{github.server_url}}/${{github.repository}}.git'
5656
noTargetBranch: 'no target branch'
57+
58+
- name: 🏃 Run Diff
59+
run: |
60+
NEW=${{ inputs.new }}
61+
OLD=${{ inputs.old }}
62+
PLATFORM=${{ inputs.platform }}
63+
PROJECT_FOLDER=${{ github.workspace }}
64+
65+
swift run public-api-diff project --new "$NEW" --old "$OLD" --platform "$PLATFORM" --output "$PROJECT_FOLDER/api_comparison.md" --log-output "$PROJECT_FOLDER/logs.txt"
66+
cat "$PROJECT_FOLDER/logs.txt"
67+
68+
if [[ ${{ env.HEAD_GITHUB_REPO != env.BASE_GITHUB_REPO }} ]]; then
69+
echo "---" >> $GITHUB_STEP_SUMMARY
70+
echo "> [!IMPORTANT]" >> $GITHUB_STEP_SUMMARY
71+
echo "> **Commenting on pull requests from forks is not possible** due to insufficient permissions." >> $GITHUB_STEP_SUMMARY
72+
echo "> Once merged, the output will be posted as an auto-updating comment under the pull request." >> $GITHUB_STEP_SUMMARY
73+
echo "---" >> $GITHUB_STEP_SUMMARY
74+
fi
75+
76+
cat "$PROJECT_FOLDER/api_comparison.md" >> $GITHUB_STEP_SUMMARY
77+
shell: bash
5778

58-
- name: 🔍 Detect Changes
59-
uses: ./ # Uses the action.yml that's at the root of the repository
60-
id: public_api_diff
79+
# We only want to comment if we're in a Pull Request and if the Pull Request is not from a forked Repository
80+
# Forked Repositories have different rights for security reasons and thus it's not possible to comment on PRs without lowering the security
81+
# once the tool is merged the base repo rights apply and the script can comment on PRs as expected.
82+
- if: ${{ github.event.pull_request.base.ref != '' && env.HEAD_GITHUB_REPO == env.BASE_GITHUB_REPO }}
83+
name: 📝 Comment on PR
84+
uses: thollander/actions-comment-pull-request@v3
6185
with:
62-
platform: "macOS"
63-
new: ${{ env.NEW_VERSION }}
64-
old: ${{ env.OLD_VERSION }}
86+
file-path: "${{ github.workspace }}/api_comparison.md"
87+
comment-tag: api_changes
88+
mode: recreate

0 commit comments

Comments
 (0)