Skip to content

OpenAPI

OpenAPI #73

Workflow file for this run

# 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