-
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (102 loc) · 3.92 KB
/
openapi.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow
name: "OpenAPI"
on:
schedule:
# Update Monday
- cron: "31 04 * * 1"
workflow_dispatch: null
permissions:
contents: "write"
pull-requests: "write"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
generate:
name: "Generate PHP client"
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
-
name: "Checkout repository"
uses: "actions/checkout@v4"
-
name: "Set up Java"
uses: "actions/setup-java@v4"
with:
distribution: "temurin"
java-version: "17"
-
name: "Install xmlstarlet"
run: |
sudo -- apt-get update
sudo -- apt-get install -y xmlstarlet
-
name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
tools: "php-cs-fixer"
coverage: "none"
-
name: "Determine OpenAPI CLI version"
id: "openapi_cli"
run: |
VERSION="$(
wget -qO- "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/maven-metadata.xml" \
| xmlstarlet sel -t -v '//metadata/versioning/versions/version[last()]'
)"
echo "version=${VERSION}" >>"${GITHUB_OUTPUT}"
-
name: "Determine latest spec version"
id: "billingo_spec"
run: |
VERSION="$(
wget -qO- "https://api.swaggerhub.com/apis/Billingo/Billingo/settings/default" \
| jq -r '."version"'
)"
echo "version=${VERSION}" >>"${GITHUB_OUTPUT}"
-
name: "Install OpenAPI"
run: |
wget -O "${{ runner.temp }}/openapi-generator-cli.jar" \
"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${{ steps.openapi_cli.outputs.version }}/openapi-generator-cli-${{ steps.openapi_cli.outputs.version }}.jar"
-
name: "Download spec"
run: |
wget -O "${{ runner.temp }}/spec.json" \
"https://api.swaggerhub.com/apis/Billingo/Billingo/${{ steps.billingo_spec.outputs.version }}?resolved=false&flatten=false"
-
name: "Clean up previously generated files"
run: |
cat .openapi-generator/FILES | xargs -- rm -f -r
-
name: "Generate client"
env:
PHP_POST_PROCESS_FILE: "php-cs-fixer fix --allow-risky yes"
run: |
java -jar "${{ runner.temp }}/openapi-generator-cli.jar" generate \
--input-spec "${{ runner.temp }}/spec.json" \
--generator-name php \
--output ./ \
--enable-post-process-file \
--additional-properties 'invokerPackage=Cone\Billingo,variableNamingConvention=camelCase,srcBasePath=src'
-
name: "Check difference to repository"
id: "list_diff"
run: |
if ! git diff --exit-code; then
echo "exit_status=1" >>"${GITHUB_OUTPUT}"
fi
-
name: "Create pull request"
if: "${{ steps.list_diff.outputs.exit_status == '1' }}"
uses: "peter-evans/create-pull-request@v5"
with:
add-paths: "./"
branch: "php-client"
commit-message: "Upgrade client"
title: "Upgrade PHP client to ${{ steps.billingo_spec.outputs.version }}"
body: |
Automated changes by running `openapi-generator-cli.jar generate`.
delete-branch: true