Skip to content

Commit 5c7aedf

Browse files
committed
4881: Update api spec action to comment on spec diff
1 parent 7a6f764 commit 5c7aedf

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

.github/workflows/api-spec.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
jobs:
1010
api-spec:
1111
runs-on: ubuntu-latest
12-
name: API specification validation
12+
name: Ensure committed API specification is up to date
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v5
@@ -28,9 +28,28 @@ jobs:
2828
task --yes api:spec:export
2929
3030
- name: Check for changes in specification
31+
id: git-diff-spec
32+
continue-on-error: true
3133
run: git diff --diff-filter=ACMRT --exit-code public/spec.yaml
3234

35+
- name: Comment PR
36+
if: steps.git-diff-spec.outcome == 'failure'
37+
working-directory: head
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
echo "## 🛑 Exported API specification file not up to date" > ../comment.md
42+
echo "" >> ../comment.md
43+
echo "Please run `task api:spec:export` to export the API specification. Then commit and push the changes." >> ../comment.md
44+
gh pr comment ${{ github.event.pull_request.number }} --body-file ../comment.md --create-if-none --edit-last
45+
46+
- name: Fail job api spec is not up to date
47+
if: steps.git-diff-spec.outcome == 'failure'
48+
run: |
49+
exit 1
50+
3351
detect-breaking-changes:
52+
name: Detect breaking changes in API specification
3453
runs-on: ubuntu-latest
3554
needs: [api-spec]
3655
steps:

public/spec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
openapi: 3.1.0
2+
# <debug>Force git diff to test github action</debug>
23
info:
34
title: 'Event Database'
45
description: 'API for the Event Database'

0 commit comments

Comments
 (0)