generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
40 lines (38 loc) · 1.51 KB
/
swagger.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Publish Swagger Specs
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up Cache
uses: actions/[email protected]
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin" # See 'Supported distributions' for available options
java-version: 21
cache: "gradle"
- name: Run Swagger Publisher
run: ./gradlew integration --tests uk.gov.hmcts.darts.common.config.SwaggerPublisherTest
- name: Commit to repository
run: |
mkdir swagger-staging
cd swagger-staging
git init
git config user.email "[email protected]"
git config user.name "Darts Gateway GitHub action"
git remote add upstream https://${{ secrets.SWAGGER_PUBLISHER_API_TOKEN }}@github.com/hmcts/cnp-api-docs.git
git pull upstream master
repo=`echo "$GITHUB_REPOSITORY" | cut -f2- -d/`
echo "$(cat /tmp/swagger-specs.json)" > "docs/specs/$repo.json"
git add "docs/specs/$repo.json"
# Only commit and push if we have changes.
git diff --quiet && git diff --staged --quiet || (git commit -m "Update spec for $repo#${GITHUB_SHA:7}"; git push --set-upstream upstream master)