Generate Go SDK #312
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
name: "Generate Go SDK" | |
on: | |
pull_request: | |
workflow_dispatch: | |
schedule: | |
# Run generation nightly on latest OpenAPI spec | |
- cron: '0 0 * * *' | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.x.x' | |
- uses: actions/[email protected] | |
with: | |
go-version: '1.21.5' | |
- name: Install kiota | |
run: dotnet tool install --global Microsoft.OpenApi.Kiota --prerelease | |
- name: Clone the existing go-sdk | |
run: | | |
cd ../ | |
git clone https://github.com/octokit/go-sdk.git | |
- name: Download latest schema | |
run: go run schemas/main.go --schema-next=false | |
- name: Run generation | |
run: kiota generate -l go --ll trace -o $(pwd)/../go-sdk/pkg/github -n "github.com/octokit/go-sdk/pkg/github/" -d schemas/downloaded.json --ebc | |
- name: Build post-processing | |
run: go build -o post-processors/go/post-processor post-processors/go/main.go | |
- name: Run post-processing | |
run: | | |
cd ../go-sdk | |
../source-generator/post-processors/go/post-processor $(pwd) | |
- name: Build generated and processed SDK | |
run: | | |
cd ../go-sdk | |
go build ./... | |
- uses: gr2m/create-or-update-pull-request-action@cd-path | |
if: github.event_name != 'pull_request' # do not update the SDK on PR builds | |
env: | |
GITHUB_TOKEN: ${{ secrets.OCTOKITBOT_PAT }} | |
with: | |
title: "Changes in generated code" | |
body: > | |
"The latest OpenAPI spec resulted in changes to the generated code. Please review, set an applicable | |
commit message, merge, and tag a release as appropriate." | |
branch: "generated-code-update" | |
author: "Octokit Bot <[email protected]>" | |
commit-message: "New updates to generated code" | |
repository: "octokit/go-sdk" | |
path-to-cd-to: "../go-sdk" |