Skip to content

/api/environments/v3 [put] (sketch) #656

/api/environments/v3 [put] (sketch)

/api/environments/v3 [put] (sketch) #656

name: API Diff
on:
pull_request:
branches:
- main
paths:
- ".github/workflows/sherlock-api-diff.yaml"
- "sherlock/**"
- "!sherlock/docs/**"
- "go-shared/**"
- "!**/*.md"
concurrency:
# Don't run this workflow concurrently on the same branch
group: ${{ github.workflow }}-${{ github.ref }}
# For PRs, don't wait for completion of existing runs, cancel them instead
cancel-in-progress: true
jobs:
api-diff:
runs-on: ubuntu-latest
permissions:
contents: "read"
# Make comments
pull-requests: "write"
steps:
- name: Checkout Base
uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
path: base
persist-credentials: false
- name: Checkout Head
uses: actions/checkout@v4
with:
path: head
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: head/sherlock/go.mod
- name: Set up Swag
working-directory: head
run: make install-swagger
- name: Generate Swagger source
working-directory: head
run: make generate-swagger
# This runs online, but if we hit issues with it, we can run it offline
# https://github.com/char0n/swagger-editor-validate/tree/master
- name: Validate Swagger source
uses: char0n/swagger-editor-validate@v1
with:
definition-file: head/sherlock/docs/swagger.yaml
- name: Create output directory
if: ${{ github.actor != 'dependabot[bot]' }}
run: mkdir output
- name: Generate diff
run: |
docker run --rm -t \
-v "$(pwd)/base/sherlock/docs:/specs/base:ro" \
-v "$(pwd)/head/sherlock/docs:/specs/head:ro" \
-v "$(pwd)/output:/output" \
openapitools/openapi-diff:latest \
--log INFO \
${{ (github.actor == 'dependabot[bot]' && '--fail-on-changed') || '--markdown /output/diff.md' }} \
/specs/base/swagger.yaml \
/specs/head/swagger.yaml
- name: Check diff
id: check-diff
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
if [[ -z $(grep '[^[:space:]]' output/diff.md) ]] ; then
echo present=false >> $GITHUB_OUTPUT
else
echo present=true >> $GITHUB_OUTPUT
fi
- name: Comment diff
if: ${{ github.actor != 'dependabot[bot]' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: api-diff
path: ${{ (steps.check-diff.outputs.present == 'true' && 'output/diff.md') || '' }}
message: |
No API changes detected