Skip to content

Commit

Permalink
Merge pull request #36 from equinix-labs/CXF-79746-auto-build-sdk
Browse files Browse the repository at this point in the history
Add GHA workflow for auto creating PR with new version of SDK
  • Loading branch information
thogarty authored Jan 12, 2024
2 parents d843ae4 + 3cbccea commit db42ea5
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
78 changes: 78 additions & 0 deletions .github/workflows/sync_sdk_with_new_api_spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
on:
workflow_dispatch:
inputs:
new_api_spec_version_number:
required: true
name: Sync SDK with New API Spec
jobs:
sync:
strategy:
matrix:
java-version: [11.0.21]
java-distribution: temurin
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"

- name: Install Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.java-distribution
cache: maven
- name: Checkout Go Code
uses: actions/checkout@v2
- name: Get next API Spec Version
id: spec_versions
run: |
API_SPEC_LINE=$(grep -i api.swaggerhub.com Makefile)
CURRENT_VERSION_NUM=$(echo $API_SPEC_LINE | cut -d / -f7)
echo "api_spec_line=$API_SPEC_LINE" >> "$GITHUB_OUTPUT"
echo "cur_version=$CURRENT_VERSION_NUM" >> "$GITHUB_OUTPUT"
- name: GitHub user
run: |
# https://api.github.com/users/github-actions[bot]
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
- name: Sync
run: |
VERSION_UPDATE="OPENAPI_URL=\"https://app.swaggerhub.com/apiproxy/registry/equinix-api/fabric/${{ github.event.inputs.new_api_spec_version_number }}\""
sed -i 's,${{ steps.spec_versions.outputs.api_spec_line }},'"$VERSION_UPDATE"',' Makefile
make generate
git commit -m 'sync: fetch ${{ steps.date.outputs.date }} spec and apply patches' *.json
git commit -m 'sync: generate client with ${{ steps.date.outputs.date }} spec' equinix-openapi-fabric
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
branch: sync/gh
branch-suffix: timestamp
title: Version ${{ steps.spec_versions.outputs.cur_version }} to ${{ github.event.inputs.new_api_spec_version_number }} API Spec Sync by GitHub Action (${{ steps.date.outputs.date }})
body: |
This API Sync PR was automated through GitHub Actions workflow_displatch
on ${{ steps.date.outputs.date }}.
This PR updates the SDK API Spec Version:
from ${{ steps.spec_versions.outputs.cur_version }} to ${{ github.event.inputs.new_api_spec_version_number }}
* Latest Swaggerhub API Spec is fetched - version ${{ github.event.inputs.new_api_spec_version_number }}
* Patches have been applied
* Generated client has been updated
## Changes in SDK
### Enhancements
-Add enhancements here-
### Breaking Changes
-Add breaking changes here-
delete-branch: true
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CRI:=docker # nerdctl
OPENAPI_CODEGEN_TAG=v6.4.0
OPENAPI_CODEGEN_IMAGE=openapitools/openapi-generator-cli:${OPENAPI_CODEGEN_TAG}
DOCKER_OPENAPI=${CRI} run --rm -u ${CURRENT_UID}:${CURRENT_GID} -v $(CURDIR):/local ${OPENAPI_CODEGEN_IMAGE}
OPENAPI_URL= https://app.swaggerhub.com/apiproxy/registry/equinix-api/fabric/4.11
OPENAPI_URL="https://app.swaggerhub.com/apiproxy/registry/equinix-api/fabric/4.11"

generate: clean fetch pre-spec-patch pull docker_generate build_client

Expand Down

0 comments on commit db42ea5

Please sign in to comment.