forked from Netflix/conductor
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jozef Volak
committed
Feb 5, 2024
1 parent
8579c13
commit c52eac4
Showing
3 changed files
with
86 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,75 @@ | ||
name: pr-check | ||
name: Swagger notiication | ||
|
||
on: | ||
pull_request: | ||
branches: [ swagger_docs ] | ||
push: | ||
branches: | ||
- swagger_docs | ||
|
||
workflow_dispatch: | ||
branches: | ||
- swagger_docs | ||
|
||
jobs: | ||
changes: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
outputs: | ||
json-file: ${{ steps.json-file.outputs.changes }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dorny/paths-filter@v3 | ||
id: json-file | ||
with: | ||
filters: | | ||
latest: | ||
- 'latest.json' | ||
staging: | ||
- 'staging.json' | ||
production: | ||
- 'production.json' | ||
base: ${{ github.ref }} | ||
|
||
diff: | ||
name: OpenAPI diff | ||
runs-on: ubuntu-latest | ||
needs: changes | ||
timeout-minutes: 5 | ||
if: ${{ needs.changes.outputs.json-file != '[]' && needs.changes.outputs.json-file != '' }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
changed-apis: ${{ fromJSON(needs.changes.outputs.json-file) }} | ||
steps: | ||
- name: Check out head branch | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
path: head | ||
|
||
- name: Check out swagger_docs branch | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: swagger_docs | ||
path: base | ||
fetch-depth: 2 | ||
|
||
- name: Check out swagger_docs branch | ||
run: cd base && git checkout HEAD^ | ||
|
||
- name: Run OpenAPI Diff (from HEAD revision) | ||
uses: docker://openapitools/openapi-diff:latest | ||
with: | ||
args: --json diff.json base/latest.json head/latest.json | ||
args: --json diff.json --text diff.txt base/latest.json head/${{ matrix.changed-apis }}.json | ||
env: | ||
JSON_FILE: ${{ matrix.changed-apis }} | ||
- name: print diff | ||
run: cat diff.json | ||
run: | | ||
slack.sh ${{ matrix.changed-apis }} | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.API_SLACK_WEBHOOK_URL }} | ||
|
||
# - name: Upload to slack step | ||
# uses: adrey/slack-file-upload-action@master | ||
# with: | ||
# token: ${{ secrets.SLACK_BOT_TOKEN }} | ||
# path: diff.json | ||
# channel: fx_api_changes |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
VERSION="${1}" | ||
|
||
json_content=$(cat diff.txt) | ||
json_string="\\n \`\`\`$json_content\`\`\`" | ||
|
||
|
||
json_string='{ | ||
"blocks": [ | ||
{ | ||
"type": "header", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Conductor API changes: '"${VERSION}"'", | ||
"emoji": true | ||
} | ||
}, | ||
{ | ||
"type": "divider" | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "'"$json_string"'" | ||
} | ||
} | ||
] | ||
}' | ||
|
||
curl -v -X POST -H 'Content-type: application/json' --data "$json_string" $API_SLACK_WEBHOOK_URL | ||
|