This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (64 loc) · 2.4 KB
/
check-specifications-update.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: check specifications update
on:
schedule:
- cron: 0 0 * * 6
workflow_dispatch: { }
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v2
- name: Cache go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go mod download
- uses: minchao/setup-go-swagger@v1
with:
version: v0.29.0
- name: Fetche all newest openapi specifications
run: make spec
- name: Generate go client libraries
run: make generate
- run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/master:refs/remotes/origin/master
git branch -r
- name: Check if openapi specifications is updateed
id: check-specifications
run: |
for spec in ./oas.*.*.json
do
IFS='.' read -r -a substrings <<< "${spec}"
target_folders="${target_folders} ${substrings[2]}"
done
target_folders=$(echo -e "${target_folders}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
git_diff_cmd="git diff refs/remotes/origin/master -- ${target_folders}"
output=$(eval "${git_diff_cmd}")
if [[ -n "${output}" ]]; then
echo '::set-output name=is-updated::true'
fi
- run: make validate
if: steps.check-specifications.outputs.is-updated == 'true'
- run: make test
if: steps.check-specifications.outputs.is-updated == 'true'
- run: make test-integration
if: steps.check-specifications.outputs.is-updated == 'true'
env:
APP_ID: ${{ secrets.APP_ID }}
APP_KEY: ${{ secrets.APP_KEY }}
- name: Create pull request
uses: peter-evans/create-pull-request@v3
if: steps.check-specifications.outputs.is-updated == 'true'
with:
token: ${{ secrets.AUTOMATION_BOT_GITHUB_TOKEN }}
commit-message: "chore(api): openapi specifications update"
branch: auto/specifications-update
title: "chore(api): openapi specifications update"
body: This PR updates specifications to the latest version
assignees: ${{ github.repository_owner }}