Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run diff against an uncommited file #496

Open
leovinsen opened this issue May 16, 2024 · 3 comments
Open

Run diff against an uncommited file #496

leovinsen opened this issue May 16, 2024 · 3 comments

Comments

@leovinsen
Copy link

Hi guys, thanks for the amazing product! I'm in the middle of POCing for my company's documentation needs. Deployment works well, but diff is not fully suited for my use case.

I am not committing the specs file into our repository and instead generate it in our CI workflow. Is it possible to run diff against the actual file inside the Github Action runner, similar to how deployment works?

name: diff OpenAPI
on:
  pull_request:
    branches:
      - development
jobs:
  api-diff:
    if: ${{ github.event_name == 'pull_request' }}
    name: Check API diff on Bump.sh
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

     - name: Generate OpenAPI specs
        run: // script to generate OpenAPI specs in ./openapi.json
        
      - name: Comment pull request with API diff
        uses: bump-sh/github-action@v1
        with:
          doc: <doc>
          token: ${{ secrets.BUMPSH_SECRET }}
          file: openapi.json
          command: diff
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@paulRbr
Copy link
Member

paulRbr commented May 16, 2024

Hi @leovinsen,

Thanks for your message!

If I understand correctly your provided action workflow, you would like to compute a diff between an already published documentation on bump.sh (your <doc> documentation slug + BUMPSH_SECRET token) and a generated openapi.json from the CI workflow. Is that correct?

It does sound like a legit use case which should already work with the current version of our GH action.
Could you show me the logs of the action run which doesn't work as you expect please?

@leovinsen
Copy link
Author

leovinsen commented May 16, 2024

Hi @paulRbr thanks for the quick response!

Yes that's correct, I would like to diff the currently deployed docs against a generated openapi.json inside the CI workflow. Something similar to bump diff openapi.json --doc <doc> --token <token> using Bump CLI.

Here is the logs:

Run bump-sh/github-action@v1
  with:
    doc: <doc>
    token: ***
    file: openapi.json
    command: diff
    fail_on_breaking: false
  env:
    GITHUB_TOKEN: ***
/usr/bin/git fetch origin 2b450d31b2f193542b2b51b39a576e52f5f83d0a 6339eecfb67991bc22a9878ca3802e1406c2c309
From https://github.com/<redacted>
 * branch                2b450d31b2f193542b2b51b39a576e52f5f83d0a -> FETCH_HEAD
 * branch                6339eecfb67991bc22a9878ca3802e1406c2c309 -> FETCH_HEAD
/usr/bin/git merge-base 2b450d31b2f193542b2b51b39a576e52f5f83d0a 6339eecfb67991bc22a9878ca3802e1406c2c309
f1a025be5a33b7b3e4f08706117b37e28ed69ea3
/usr/bin/git --work-tree tmp/ restore -s f1a025be5a33b7b3e4f08706117b37e28ed69ea3 .
/usr/bin/git restore -s 6339eecfb67991bc22a9878ca3802e1406c2c309 .
No diff found, nothing more to do.

I observe that it checks out from 2 branches and then performs comparison on the two openapi.json file found on both branches. To test my theory:

  • I tried removing the step that generates openapi.json, and it fails for deploy but not diff
  • I tried commiting openapi.json, and it finally printed the diff results on my PR

@paulRbr
Copy link
Member

paulRbr commented May 23, 2024

Hi @leovinsen,

Sorry for the late reply. I took some time to try this out and I can't seem to reproduce the error with a generated API definition file.

Here's my test on our examples repo: https://github.com/bump-sh/examples/pull/35/files which lead to a correct diff.

Could you try to reproduce on a public repo so I can see both the git repository, the action workflow and the action logs?

Thanks a lot for your help 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants