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

Create a GH workflow example, when PR merge registers a version / assigns a stage #277

Open
aguschin opened this issue Sep 23, 2022 · 7 comments
Labels
enhancement New feature or request product Product work is needed

Comments

@aguschin
Copy link
Contributor

aguschin commented Sep 23, 2022

Some users may want to register new version / assign a stage to a specific artifact when PR is merged. This could be achieved by creating a GH workflow that does this. Few questions:

  1. How to know which artifact to register? Which semver to use? Which stage to assign? (Maybe Labels? I've seen some tools that bump project's semver based on PR labels like minor, major, patch). What if there are multiple artifacts to register/assign stages to?
  2. Should we add an example of this workflow in gto-example repo?
  3. Does it influence GTO/DVC integration in any way?
@aguschin aguschin added enhancement New feature or request product Product work is needed labels Sep 23, 2022
@quandanrepo
Copy link

Just noticed this issue/ suggestion - this would be something that I would be quite interesting in!
In the meantime, I have tried to implement a gto register step (Github Actions) upon a pull request being merged and running into an error.

For the Github Action that has been set up:

Register-New-Model:
  if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
    - name: Install packages to register model
      run: |
        pip install gto
    - name: Register Model
      run: |
        REGISTER_MODEL_NAME=$(echo ${{ github.event.pull_request.head.ref }} | awk -F"-" '{print $1}')
        git config user.name "Github-Bot"
        git config user.email "[email protected]"
        gto register ${REGISTER_MODEL_NAME}

The error that I get is:

Created git tag '[email protected]' that registers version
Running `git push origin [email protected]`
❌ The command `git push origin [email protected]` failed. Make sure your local 
repository is in sync with the remote.

I have tried replacing this gto register step with git tag [email protected] and this correctly add the corresponding tag.
Is there something that is missing to use gto register in this manner?

@shcheklein
Copy link
Member

I have tried replacing this gto register step with git tag [email protected] and this correctly add the corresponding tag.
Is there something that is missing to use gto register in this manner?

did git push work for this tag? (I assume git tag alone is not enough, we need to save it back to GitHub)

@quandanrepo
Copy link

Sorry, I meant I replaced it with

git tag [email protected]
git push origin [email protected]

which does add the tag as expected

@shcheklein
Copy link
Member

Could you please try to run it with -v: gto -v ...?

is there a small repo example, that I could fork to reproduce it?

@quandanrepo
Copy link

quandanrepo commented Sep 13, 2023

I've added -v but seemingly, get the same error message with no extra debugging information

I've create a dummy repo: https://github.com/quandanrepo/PR-Merge-Register
which has the same workflow - so just checking out the main branch and trying to register commit as a tag
I have set this action to run on any pushes for now just to make it easier to test.

@shcheklein
Copy link
Member

@quandanrepo thanks! I think I understand the core issue here. It's the same as described here iterative/scmrepo#262 . The workaround is avoid pushing on the gto register and use git directly. It depends on the #405 .

Until #405 is solved in some way, you could ignore the error from the gto command and run git manually.

Could you please try and let me know if that works as a workaround for now?

@quandanrepo
Copy link

Thanks for the additional information and suggestion!
I have bypassed the gto register step with an annotated tag and push step, which works for now and can be shown using the gto show command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request product Product work is needed
Projects
None yet
Development

No branches or pull requests

3 participants