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

[feature] cz action to output commit sha #98

Open
reinthal opened this issue Jan 27, 2025 · 0 comments
Open

[feature] cz action to output commit sha #98

reinthal opened this issue Jan 27, 2025 · 0 comments

Comments

@reinthal
Copy link

Feature:

Commitizen gh action outputs the sha of the commit as an output to be used for downstream builds

   steps:
      - uses: actions/checkout@v4
        with:
          ref: ${steps.cz.outputs.sha}

Background

We want to display the current build to the user in the UI of an api we are making with fastapi. To do this, we use the version in the pyproject.toml. However, Github actions does not checkout the latest commit on checkout, only the commit that triggered the gh workflow. Thus, when we add the version information before building the container, the latest commit from commitizen action is not added to the checked out code that builds the container. To solve this, we can add the following to our workflow:

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          ref: main

according to this issue in gh checkout action actions/checkout#439. However, this this is sub-optimal for larger codebase where someone could merge to main between the commitizen bump and the gh action checkout operation. This would result in subsequent build of the wrong codebase. Suggested solution is to output the sha in the commitizen action when a commit is made so the sha can be used for subsequent checkouts.

   steps:
      - uses: actions/checkout@v4
        with:
          ref: ${steps.cz.outputs.sha}
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

1 participant