asyncapi / github-action-for-cli

GitHub Action with generator, validator, converter and others - all in one for your AsyncAPI documents with AsyncAPI CLI as backbone
Apache License 2.0
50 stars 19 forks source link

[BUG] Generate command don't generate output file for GoLang #402

Closed vtiwari227 closed 3 months ago

vtiwari227 commented 3 months ago

Describe the bug.

Hello, I'm using async api Github action to generate Golang model objects based on Aysnc API spec. In Github action summary, I do see object being (based on response of Github action logs) created but i don't see output file being generated.

Expected behavior

Output file with the expected model object should be created

Screenshots

NA

How to Reproduce

Below is the markdown I'm using to generate model objects

name: AsyncAPI model object generation for Go language

on:
  pull_request:
    branches: [ main ]

jobs:
  generate-models:
    runs-on: ubuntu-latest
    steps:
    #"standard step" where repo needs to be checked-out first
    - name: Checkout repo
      uses: actions/checkout@v2

    - name: Generating models from my AsyncAPI document
      uses: asyncapi/github-action-for-cli@v3.1.1 # You can use any version you want
      with:
        command: generate
        filepath: docs/api/async-api.yml
        language: golang
        parameters: --packageName=models
        output: docs/api/generated-models

🥦 Browser

Google Chrome

👀 Have you checked for similar open issues?

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

github-actions[bot] commented 3 months ago

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

Shurtu-gal commented 3 months ago

@vtiwari227 the workflow is working https://github.com/ash17290/test-repo/actions/runs/10496567662/job/29077507131#step:4:107.

Could you maybe provide the asyncapi document used for which it failed?

vtiwari227 commented 3 months ago

@Shurtu-gal Where does the output file generated ?, I don't see folder for given path in Github repo "docs/api/generated-models". Thanks

Shurtu-gal commented 3 months ago

@Shurtu-gal Where does the output file generated ?, I don't see folder for given path in Github repo "docs/api/generated-models". Thanks

For this you need to add a step to create a commit for the changes done in the action. Example workflow for PR:

name: Test

on:
  - workflow_dispatch
  - push

jobs:
  generate-models:
    runs-on: ubuntu-latest
    steps:
    #"standard step" where repo needs to be checked-out first
    - name: Checkout repo
      uses: actions/checkout@v2

    - name: Generating models from my AsyncAPI document
      uses: asyncapi/github-action-for-cli@v3.1.1 # You can use any version you want
      with:
        command: generate
        filepath: asyncapi.yml
        language: golang
        parameters: --packageName=models
        output: docs/api/generated-models

    - name: Fix permissions
      run: sudo chown -R $USER:$USER .

    - name: Create Pull Request
      uses: peter-evans/create-pull-request@v6

Successful Run: https://github.com/ash17290/test-repo/actions/runs/10507173258/job/29108489301 PR: https://github.com/ash17290/test-repo/pull/3

vtiwari227 commented 3 months ago

Thank you so much, I was able to get the model object exported with the above approach. Should be good to close the ticket