-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Github actions workflow into two jobs: 1) Version check if a client needs to be generated 2) Generate new client with git tag/release Moved templates into .github folder, and deleted the build folder/files. removed .gitignore from repo.
- Loading branch information
1 parent
f6e3ea3
commit f5072ce
Showing
28 changed files
with
44 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,69 @@ | ||
name: Generate OpenAPI | ||
name: Generate OpenAPI Client | ||
on: | ||
push: | ||
branches: | ||
- main | ||
schedule: ## Schedule the job to run bi-weekly at 8AM. | ||
- cron: '* 8 1,15 * *' | ||
jobs: | ||
check-for-updates: | ||
runs-on: ubuntu-latest | ||
env: | ||
OPENAPI_REPO: "https://raw.githubusercontent.com/meraki/openapi/master/openapi/spec2.json" | ||
CLIENT_REPO: "https://api.github.com/repos/meraki/dashboard-api-go/releases/latest" | ||
outputs: | ||
result: ${{ steps.generate-new-client.outputs.RESULT }} | ||
current: ${{ steps.generate-new-client.outputs.CURRENT }} | ||
new: ${{ steps.generate-new-client.outputs.NEW }} | ||
steps: | ||
- name: "Install JSON Parser" | ||
run: sudo apt update && sudo apt install -y jq | ||
- name: "Get Previous API Version" | ||
run: echo "CURRENT_API_VERSION=$(curl -s GET $CLIENT_REPO | jq -r '.tag_name' | head -n1)" >> $GITHUB_ENV | ||
- name: "Get New API Version" | ||
run: echo "NEW_API_VERSION=v$(curl $OPENAPI_REPO | jq '.info.version' | tr -d '\"')" >> $GITHUB_ENV | ||
- name: "Export Results" | ||
id: generate-new-client | ||
run: | | ||
echo "NEW=${{ env.NEW_API_VERSION }}" >> $GITHUB_OUTPUT | ||
echo "CURRENT=${{ env.CURRENT_API_VERSION }}" >> $GITHUB_OUTPUT | ||
if [ "${{ env.NEW_API_VERSION }}" = "${{ env.CURRENT_API_VERSION }}" ]; then | ||
echo "RESULT=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "RESULT=true" >> $GITHUB_OUTPUT | ||
fi | ||
generate-client: | ||
needs: check-for-updates | ||
runs-on: ubuntu-latest | ||
if: needs.check-for-updates.outputs.result == 'true' | ||
steps: | ||
- name: "Checkout Repository" | ||
uses: actions/checkout@v2 | ||
- name: "Set Version" | ||
run: echo "API_VERSION=$(cat meraki-openapi-version.txt | tr -d '\n')" >> $GITHUB_ENV | ||
working-directory: ./build | ||
uses: actions/checkout@v3 | ||
- name: "Fetch Specification" | ||
run: wget https://github.com/meraki/openapi/archive/refs/tags/${{ needs.check-for-updates.outputs.new }}.zip && unzip -j ${{ needs.check-for-updates.outputs.new }}.zip '*/spec2.json' | ||
- name: "Install JRE" | ||
run: sudo apt update && sudo apt install -y default-jre | ||
- name: "Fetch Specification" | ||
run: wget https://github.com/meraki/openapi/archive/refs/tags/$API_VERSION.zip && unzip -j $API_VERSION.zip '*/spec2.json' | ||
- name: "Install OpenAPI Generator" | ||
run: wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/5.3.0/openapi-generator-cli-5.3.0.jar -O openapi-generator-cli.jar | ||
- name: "Run OpenAPI Generator" | ||
run: rm -rf client/; java -jar openapi-generator-cli.jar generate -i spec2.json -g go -o client -p enumClassPrefix=true -p structPrefix=true --package-name client -p packageVersion=$API_VERSION --git-user-id meraki --git-repo-id dashboard-api-go/client --git-host github.com | ||
- name: "Timestamp" | ||
run: date > generated_at.txt | ||
working-directory: ./build | ||
run: rm -rf client/; java -jar openapi-generator-cli.jar generate -i spec2.json -g go -o client -p enumClassPrefix=true -p structPrefix=true --package-name client -p packageVersion=${{ needs.check-for-updates.outputs.new }} -t .github/templates --git-user-id meraki --git-repo-id dashboard-api-go/client --git-host github.com | ||
- name: "Cleanup" | ||
run: rm openapi-generator-cli.jar; rm spec2.json; rm $API_VERSION.zip | ||
run: rm openapi-generator-cli.jar; rm spec2.json; rm ${{ needs.check-for-updates.outputs.new }}.zip | ||
- name: "Git Config" | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "<>" | ||
- name: "Git Commit" | ||
run: | | ||
git add -A | ||
git commit -m "OpenAPI client generation $API_VERSION" | ||
git tag $API_VERSION | ||
git commit -m "OpenAPI client generation ${{ needs.check-for-updates.outputs.new }}" | ||
git tag ${{ needs.check-for-updates.outputs.new }} | ||
git push origin main | ||
git push origin $API_VERSION | ||
git push origin ${{ needs.check-for-updates.outputs.new }} | ||
- name: Create a GitHub release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ env.API_VERSION }} | ||
name: Release ${{ env.API_VERSION }} | ||
body: Meraki Golang Dashboard API ${{ env.API_VERSION }} | ||
tag: ${{ needs.check-for-updates.outputs.new }} | ||
name: Release ${{ needs.check-for-updates.outputs.new }} | ||
body: Meraki Golang Dashboard API ${{ needs.check-for-updates.outputs.new }} |
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.