-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
52 lines (45 loc) · 1.61 KB
/
action.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
name: gh-action-test-tostones
description: "Check for breaking changes in API specifications"
inputs:
file_path:
description: "Path to the API specification that you want to compare"
required: true
access_token:
description: "API Evolution Management Service access token"
required: true
runs:
using: "composite"
steps:
- name: Checkout main branch
uses: actions/checkout@v2
with:
ref: main
path: main
- name: Checkout current branch
uses: actions/checkout@v2
with:
path: current
- name: Check for breaking changes
shell: bash
run: |
before_file_path="${GITHUB_WORKSPACE}/main/${{ inputs.file_path }}"
after_file_path="${GITHUB_WORKSPACE}/current/${{ inputs.file_path }}"
api_url="https://qlq2x2wbi74vc4h6hvjgc5szky0phost.lambda-url.us-east-2.on.aws/"
if [ -f "${before_file_path}" ] && [ -f "${after_file_path}" ]; then
response=$(curl -s -o /dev/null -X POST \
-w "%{http_code}" \
"${api_url}" \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer ${{ inputs.access_token }}" \
-F "before=@${before_file_path}" \
-F "after=@${after_file_path}")
echo "API Evolution Management Service returned an ${response} HTTP status code."
if [ "${response}" -eq 400 ]; then
echo "Breaking changes detected!"
exit 1
else
echo "No breaking changes detected."
fi
else
echo "File not found in either main or current branch."
fi