-
Notifications
You must be signed in to change notification settings - Fork 122
65 lines (55 loc) · 1.99 KB
/
detect_api_changes.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: 👀 Detect public API changes
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
new:
description: 'Branch/tag of the new/updated version'
required: true
old:
description: 'Branch/tag of the old/comparison version'
required: true
jobs:
build:
runs-on: macos-14 # Apple Silicon Runner
steps:
- uses: actions/checkout@v4
- uses: n1hility/cancel-previous-runs@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Select latest Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: 🚚 Fetch repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🔍 Detect Changes
run: |
PROJECT_FOLDER=$PWD
NEW="${{ env.source }}~${{ env.githubRepo }}"
if [[ '${{ github.head_ref || env.noTargetBranch }}' == 'release/*' ]]
then
LATEST_TAG=$(git describe --tags --abbrev=0)
OLD="$LATEST_TAG~${{ env.githubRepo }}"
else
OLD="${{ env.target }}~${{ env.githubRepo }}"
fi
cd Scripts
./public-api-diff project --new "$NEW" --old "$OLD" --output "$PROJECT_FOLDER/api_comparison.md" --log-output "$PROJECT_FOLDER/logs.txt"
cat "$PROJECT_FOLDER/logs.txt"
cat "$PROJECT_FOLDER/api_comparison.md" >> $GITHUB_STEP_SUMMARY
env:
source: '${{ github.event.inputs.new || github.head_ref }}'
target: '${{ github.event.inputs.old || github.event.pull_request.base.ref }}'
githubRepo: '${{github.server_url}}/${{github.repository}}.git'
noTargetBranch: 'no target branch'
- if: ${{ github.event.pull_request.base.ref != '' }}
name: 📝 Comment on PR
uses: thollander/actions-comment-pull-request@v3
with:
file-path: "${{ github.workspace }}/api_comparison.md"
comment-tag: api_changes
mode: recreate