Skip to content

Commit 6495611

Browse files
author
Jozef Volak
committed
test diff
1 parent 8579c13 commit 6495611

File tree

3 files changed

+87
-8
lines changed

3 files changed

+87
-8
lines changed

.github/workflows/openapi_diff.yml

+54-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,76 @@
1-
name: pr-check
1+
name: Swagger notiication
22

33
on:
4-
pull_request:
5-
branches: [ swagger_docs ]
4+
push:
5+
branches:
6+
- swagger_docs
67

78
workflow_dispatch:
9+
branches:
10+
- swagger_docs
811

912
jobs:
13+
changes:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
outputs:
17+
json-file: ${{ steps.json.outputs.changes }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 2
22+
- uses: dorny/paths-filter@v3
23+
id: json
24+
with:
25+
base: ${{ github.ref }}
26+
filters: |
27+
latest:
28+
- 'latest.json'
29+
staging:
30+
- 'staging.json'
31+
production:
32+
- 'production.json'
33+
1034
diff:
1135
name: OpenAPI diff
1236
runs-on: ubuntu-latest
1337
timeout-minutes: 5
38+
# if: ${{ needs.changes.outputs.json-file != '[]' && needs.changes.outputs.json-file != '' }}
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
changed-apis: ${{ fromJSON(needs.changes.outputs.json-file) }}
1443
steps:
1544
- name: Check out head branch
16-
uses: actions/checkout@v3
45+
uses: actions/checkout@v4
1746
with:
1847
path: head
48+
1949
- name: Check out swagger_docs branch
20-
uses: actions/checkout@v3
50+
uses: actions/checkout@v4
2151
with:
2252
ref: swagger_docs
2353
path: base
54+
fetch-depth: 2
55+
56+
- name: Check out swagger_docs branch
57+
run: cd base && git checkout HEAD^
58+
2459
- name: Run OpenAPI Diff (from HEAD revision)
2560
uses: docker://openapitools/openapi-diff:latest
2661
with:
27-
args: --json diff.json base/latest.json head/latest.json
62+
args: --json diff.json --text diff.txt base/${JSON_FILE}.json head/${JSON_FILE}.json
63+
env:
64+
JSON_FILE: ${{ matrix.changed-apis }}
2865
- name: print diff
29-
run: cat diff.json
66+
run: |
67+
slack.sh ${{ matrix.changed-apis }}
68+
env:
69+
SLACK_WEBHOOK: ${{ secrets.API_SLACK_WEBHOOK_URL }}
70+
71+
# - name: Upload to slack step
72+
# uses: adrey/slack-file-upload-action@master
73+
# with:
74+
# token: ${{ secrets.SLACK_BOT_TOKEN }}
75+
# path: diff.json
76+
# channel: fx_api_changes

latest.json

+1-1
Large diffs are not rendered by default.

slack.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
VERSION="${1}"
3+
4+
json_content=$(cat diff.txt)
5+
json_string="\\n \`\`\`$json_content\`\`\`"
6+
7+
8+
json_string='{
9+
"blocks": [
10+
{
11+
"type": "header",
12+
"text": {
13+
"type": "plain_text",
14+
"text": "Conductor API changes: '"${VERSION}"'",
15+
"emoji": true
16+
}
17+
},
18+
{
19+
"type": "divider"
20+
},
21+
{
22+
"type": "section",
23+
"text": {
24+
"type": "mrkdwn",
25+
"text": "'"$json_string"'"
26+
}
27+
}
28+
]
29+
}'
30+
31+
curl -v -X POST -H 'Content-type: application/json' --data "$json_string" $API_SLACK_WEBHOOK_URL
32+

0 commit comments

Comments
 (0)