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

plugin: add gh cli to vela-git #975

Open
plyr4 opened this issue May 10, 2024 · 4 comments
Open

plugin: add gh cli to vela-git #975

plyr4 opened this issue May 10, 2024 · 4 comments
Labels
area/plugin Indicates a change to a plugin enhancement Indicates an improvement to a feature

Comments

@plyr4
Copy link
Contributor

plyr4 commented May 10, 2024

Description

it would be sweet if users could automatically interact with git using gh the official cli.

we can add it to the plugin, meaning, throw in a gh installation into the Dockerfile and call it good
https://github.com/go-vela/vela-git/blob/main/Dockerfile#L19

but i dont think gh supports using the netrc for gh auth login so it likely wont work "out of the box" for users unless they provide a PAT

cli/cli#288
cli/cli#3623

so... if we figure out auth, or move Vela away from netrc then this will be easier.
or we can just install gh and let users figure that out on their own, but i dont think thats the best user experience. personally, i would expect it to "just work".

@plyr4 plyr4 added enhancement Indicates an improvement to a feature area/plugin Indicates a change to a plugin labels May 10, 2024
@colindean
Copy link

I'm okay with the baby steps approach. Add in the CLI pkg and let the user figure out how to get the token in there for now. Maybe someone will come along and add netrc support in cli/cli#288 or Vela or this plugin can provision an envvar secret or build the gh-compatible config at runtime.

colindean added a commit to colindean/vela-git that referenced this issue May 10, 2024
This is baby steps toward go-vela/community#975. Getting credentials in place remains an exercise left to the consumer.
@colindean
Copy link

I think it might be possible to write a simple netrc -> gh hosts.yaml converter.

machine git.mycompany.com login myusername password gho_0000000000000000000
git.mycompany.com:
    user: myusername
    oauth_token: gho_0000000000000000000
    git_protocol: https
    users:
        myusername:
            oauth_token: gho_0000000000000000000

https://pkg.go.dev/golang.org/x/tools/cmd/auth/netrcauth provides a netrc impl, could spit out the YAML without much fuss.

Could include it as a separate tool or a subcommand of vela-git, invocable like:

steps:
  - name: Convert netrc to gh yaml
    image: target/vela-git:latest
    commands:
      # subcommand
      - vela-git convert-netrc-to-gh-hosts
      # helper script
      - convert-netrc-to-gh-hosts
  - name: Do stuff with gh
    image: target/vela-git:latest
    commands:
      # subcommand
      - gh pr list

@colindean
Copy link

@colindean
Copy link

I polished up something for myself: colindean/hejmo@0062264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugin Indicates a change to a plugin enhancement Indicates an improvement to a feature
Projects
None yet
Development

No branches or pull requests

2 participants