Skip to content

Commit

Permalink
test diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Volak committed Feb 5, 2024
1 parent 8579c13 commit 005a686
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 8 deletions.
59 changes: 52 additions & 7 deletions .github/workflows/openapi_diff.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,74 @@
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
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/${JSON_FILE}.json head/${JSON_FILE}.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
2 changes: 1 addition & 1 deletion latest.json

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions slack.sh
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

0 comments on commit 005a686

Please sign in to comment.