Skip to content

Generate API Client #640

Generate API Client

Generate API Client #640

Workflow file for this run

name: Generate API Client
on:
workflow_dispatch:
permissions:
contents: read
jobs:
gen-api:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
app-id: ${{ secrets.CQ_APP_ID }}
private-key: ${{ secrets.CQ_APP_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
- name: Generate GitHub App token for cloud repo
id: app-token-cloud
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3
with:
app-id: ${{ secrets.CQ_APP_ID }}
private-key: ${{ secrets.CQ_APP_PRIVATE_KEY }}
repositories: |
cloud
permission-contents: read
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
token: ${{ steps.app-token.outputs.token }}
- name: Get Specs File
run: |
curl -H "Authorization: token ${{ steps.app-token-cloud.outputs.token }}" https://raw.githubusercontent.com/cloudquery/cloud/main/cloud/internal/servergen/spec.json -o spec.json
- name: Format Specs File
run: |
docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli:v7.5.0 generate -i /local/spec.json -g openapi --skip-validate-spec -o /local/.generated
cp .generated/openapi.json spec.json
sudo rm -rf .generated
- name: Set up Go 1.x
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6
with:
go-version-file: go.mod
- name: Regenerate client
run: |
go generate ./...
- name: Create Pull Request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
with:
# required so the PR triggers workflow runs
token: ${{ steps.app-token.outputs.token }}
branch: fix/gen-cloudquery-api
base: main
title: 'fix: Generate CloudQuery Go API Client from `spec.json`'
commit-message: 'fix: Generate CloudQuery Go API Client from `spec.json`'
body: This PR was created by a scheduled workflow to generate the CloudQuery Go API Client from `spec.json`
labels: automerge