{"id":21658052,"url":"https://github.com/LinuxSuRen/gogit","last_synced_at":"2025-07-17T20:32:42.722Z","repository":{"id":63999222,"uuid":"572325144","full_name":"LinuxSuRen/gogit","owner":"LinuxSuRen","description":"Sending build status to different git providers","archived":false,"fork":false,"pushed_at":"2024-05-30T08:05:34.000Z","size":137,"stargazers_count":16,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-17T13:02:53.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LinuxSuRen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-30T02:50:10.000Z","updated_at":"2024-10-24T12:15:34.000Z","dependencies_parsed_at":"2024-04-22T07:57:21.564Z","dependency_job_id":null,"html_url":"https://github.com/LinuxSuRen/gogit","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinuxSuRen%2Fgogit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinuxSuRen%2Fgogit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinuxSuRen%2Fgogit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinuxSuRen%2Fgogit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LinuxSuRen","download_url":"https://codeload.github.com/LinuxSuRen/gogit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226304331,"owners_count":17603568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-25T09:28:36.265Z","updated_at":"2024-11-25T09:28:37.982Z","avatar_url":"https://github.com/LinuxSuRen.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![codecov](https://codecov.io/gh/LinuxSuRen/gogit/branch/master/graph/badge.svg?token=mnFyeD2IQ7)](https://codecov.io/gh/LinuxSuRen/gogit)\r\n\r\n`gogit` could send the build status to different git providers. Such as:\r\n\r\n* GitHub\r\n* Gitlab (public or private)\r\n\r\n## Usage\r\n\r\n### Generate commit message with AI\r\n\r\n```shell\r\nexport AI_PROVIDER=your-one-api-server-address\r\nexport ONEAPI_TOKEN=your-one-api-token\r\n\r\ngogit commit\r\n```\r\n\r\nIt supports [one-api](https://github.com/songquanpeng/one-api) only.\r\n\r\n### Checkout to branch or PR\r\nIdeally, `gogit` could checkout to your branch or PR in any kind of git repository.\r\n\r\nYou can run the following command in a git repository directory:\r\n\r\n```shell\r\ngogit checkout --pr 1\r\n```\r\n\r\n### Send status to Git Provider\r\nBelow is an example of sending build status to a private Gitlab server:\r\n\r\n```shell\r\ngogit status --provider gitlab \\\r\n  --server http://10.121.218.82:6080 \\\r\n  --repo yaml-readme \\\r\n  --pr 1 \\\r\n  --username linuxsuren \\\r\n  --token h-zez9CWzyzykbLoS53s\r\n```\r\n\r\nOr in the following use cases:\r\n\r\n* [Tekton Task](https://hub.tekton.dev/tekton/task/gogit)\r\n\r\n### Send a notification to DingDing\r\nBelow is an example of sending a notification to DingDing based on the Gitlab/GitHub pull request author/reviewers/assignees:\r\n\r\n```shell\r\ngogit pr --provider gitlab \\\r\n  --server http://10.121.218.82:6080 \\\r\n  --repo yaml-readme \\\r\n  --pr 1 \\\r\n  --username linuxsuren \\\r\n  --token h-zez9CWzyzykbLoS53s \\\r\n  --msg 'workflow done' \\\r\n  --dingding-tokens linuxsuren=dingdingtoken\r\n```\r\n\r\n## Argo workflow Executor\r\nInstall as an Argo workflow executor plugin:\r\n\r\n```shell\r\ncat \u003c\u003cEOF | kubectl apply -f -\r\n---\r\napiVersion: v1\r\nkind: ServiceAccount\r\nmetadata:\r\n  name: gogit-executor-plugin\r\n  namespace: default\r\n---\r\napiVersion: v1\r\ndata:\r\n  sidecar.automountServiceAccountToken: \"true\"\r\n  sidecar.container: |\r\n    args:\r\n    - status\r\n    - --provider\r\n    - gitlab\r\n    - --target\r\n    - http://argo.argo-server.svc:2746                        # should be an external address\r\n    - --create-comment=true                                   # create a comment to show the status of Workflow\r\n    image: ghcr.io/linuxsuren/workflow-executor-gogit:master\r\n    command:\r\n    - workflow-executor-gogit\r\n    name: gogit-executor-plugin\r\n    ports:\r\n    - containerPort: 3001\r\n    resources:\r\n      limits:\r\n        cpu: 500m\r\n        memory: 128Mi\r\n      requests:\r\n        cpu: 250m\r\n        memory: 64Mi\r\n    securityContext:\r\n      allowPrivilegeEscalation: true\r\n      runAsNonRoot: true\r\n      runAsUser: 65534\r\nkind: ConfigMap\r\nmetadata:\r\n  creationTimestamp: null\r\n  labels:\r\n    workflows.argoproj.io/configmap-type: ExecutorPlugin\r\n  name: gogit-executor-plugin\r\n  namespace: argo\r\nEOF\r\n```\r\n\r\nthen, create a WorkflowTemplate:\r\n```shell\r\ncat \u003c\u003cEOF | kubectl apply -f -\r\napiVersion: argoproj.io/v1alpha1\r\nkind: WorkflowTemplate\r\nmetadata:\r\n  name: plugin\r\n  namespace: default\r\nspec:\r\n  entrypoint: main\r\n  hooks:\r\n    exit:\r\n      template: status\r\n    all:\r\n      template: status\r\n      expression: \"true\"\r\n  templates:\r\n  - container:\r\n      args:\r\n        - search\r\n        - kubectl\r\n      command:\r\n        - hd\r\n      image: ghcr.io/linuxsuren/hd:v0.0.70\r\n    name: main\r\n  - name: status\r\n    plugin:\r\n      gogit-executor-plugin:\r\n        owner: linuxsuren\r\n        repo: test\r\n        pr: \"3\"\r\n        label: test\r\nEOF\r\ncat \u003c\u003cEOF | kubectl create -f -\r\napiVersion: argoproj.io/v1alpha1\r\nkind: Workflow\r\nmetadata:\r\n  generateName: plugin\r\n  namespace: default\r\nspec:\r\n  workflowTemplateRef:\r\n    name: plugin\r\nEOF\r\n```\r\n\r\nIt could create (and update) a comment on target pull request to show the status of the Workflow. See also:\r\n\r\n```yaml\r\nhello-world is Succeeded. It takes 3m30.19239846s. Please check log output from [here](https://10.121.218.184:30298/workflows/default/hello-world-r2lqm).\r\n\r\n| Stage | Status | Duration |\r\n|---|---|---|\r\n| test | Succeeded | 38s |\r\n| scan | Succeeded | 54s |\r\n| build | Succeeded | 2m54s |\r\n| clone | Succeeded | 26s |\r\n| check | Succeeded | 33s |\r\n| build(0) | Succeeded | 2m44s |\r\n\r\n\r\nComment from [gogit](https://github.com/linuxsuren/gogit).\r\n```\r\n\r\n## TODO\r\n* Support more git providers\r\n\r\n## Thanks\r\nThanks to these open source projects, they did a lot of important work.\r\n* github.com/jenkins-x/go-scm\r\n* github.com/spf13/cobra\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLinuxSuRen%2Fgogit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLinuxSuRen%2Fgogit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLinuxSuRen%2Fgogit/lists"}