-
Notifications
You must be signed in to change notification settings - Fork 21
78 lines (67 loc) · 2.37 KB
/
change.yaml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Check for API breaks
on:
pull_request_target:
branches:
- main
jobs:
check:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --depth=1 --tags
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Check for API breaks
continue-on-error: true
id: check
run: |
pip install griffe
griffe check "openfe" --verbose -a origin/main
griffe check "openfecli" --verbose -a origin/main
- name: Manage PR Comments
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const identifier = '<!-- api-break-check -->';
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const stepUrl = `${runUrl}#step:check`;
// Determine the outcome of the check step
const checkStepOutcome = '${{ steps.check.outcome }}';
// List existing comments
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
// Delete previous comments from this action
for (const comment of comments) {
if (comment.body.includes(identifier)) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}
}
// Post a new comment only if the check step failed
if (checkStepOutcome === 'failure') {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `${identifier}\n🚨 API breaking changes detected! 🚨\n[View logs for this step](${stepUrl})`
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `${identifier}\nNo API break detected ✅`
});
}