Giter Site home page Giter Site logo

gh-sync's Introduction

gh-sync: Tool for pulling public issues into private tracking

If your team manages public GitHub issues for open source repositories as well as internal tracking with Azure Devops (ADO), gh-sync can mirror the two while keeping internal information secure. The gh-sync project includes a Dockerfile from which the project is containerized to be used by a GitHub Action workflow. By using gh-sync as a GitHub Action or command line tools, individual contributors (ICs) are able to increase productivity and visibility as any changes to GitHub issues are reflected with their ADO issue counterparts.

# Create or update an ADO bug for <GitHub Organization>/<GitHub Project>#500.
gh-sync pull-gh <GitHub Organization>/<GitHub Project> 500

# Create or update all ADO issues with the "tracking" label from <GitHub Organization>/<GitHub Project>.
gh-sync pull-all-gh <GitHub Organization>/<GitHub Project>

# Find existing ADO work item or bug for <GitHub Organization>/<GitHub Project>#500
gh-sync find-ado <GitHub Organization>/<GitHub Project> 500

# Show a text representation of ADO issue #31795.
gh-sync get-ado 31795

Prerequisites

  • Windows 10
  • .NET 6 Preview 7 or later
  • A personal access token (PAT) for Azure DevOps

Using gh-sync as a GitHub Action

A GitHub Action is the recommended way to include gh-sync to your repositories. Simply create a new action under <YourGitRepo>/.github/worfklows/<YourAction>.yml to specify when gh-sync should be called. Your action can be specified to specific issue events or applied to only specific labels for automatic mirroring between GitHub and ADO issues.

The below example will trigger a workflow whenever an issue is modified as well as when there are any issue comments. Events are then filtered by the 'tracking' label. The only variables that must be configured are the ado organization url, project, area-path and a personal access token (PAT) to access ADO.

name: Sync GitHub with ADO

on: 
  issues:
    types: [closed, edited, deleted, reopened, assigned, unassigned, labeled, unlabeled]
  issue_comment:

jobs:
  build:
    name: Run gh-sync from GitHub action
    if: ${{ github.event.label.name == 'tracking' || contains(github.event.issue.labels.*.name, 'tracking') }} # Filters out issues/events without the 'tracking' label
    runs-on: ubuntu-latest
    steps:
      - name: 'Trigger gh-sync'
        uses: microsoft/gh-sync@main
        with:
          ado-organization-url: 'https://<ado-project-url>'
          ado-project: '<ADO Project>'
          ado-area-path: '<ADO Project>/<Team Name>'
          github-repo: '<GitHub Organization>/<GitHub Project>'
          issue-number: ${{github.event.issue.number}} # Auto-generated from GitHub action
          ado-token: ${{ secrets.AZURE_DEVOPS_TOKEN }} # Your Personal Access Token (PAT)
          github-token: ${{ secrets.GITHUB_TOKEN }}    # Auto-generated from GitHub action

You can customize gh-sync to fit your own team's specific needs by simply forking this repository and pointing to the new location at the uses: keyword.

Using gh-sync via PowerShell

If you want to use gh-sync manually during your daily work, simply clone this repository and run the install.ps1 script at the root of gh-sync. This will add gh-sync to your PATH and validate you are running Windows 10 or later.

./install.ps1

You will then need to set the following environment variables:

> $Env:ADO_URI='https://<ado-project-uri>'
> $Env:ADO_PROJECT='<ADO Project>'
> $Env:AREA_PATH='<ADO Area Path>'
> $Env:ADO_TOKEN='<Your ADO PAT>'
> $Env:GITHUB_TOKEN='<Your GitHub PAT>'

You can now run gh-sync:

> gh-sync pull-gh <GitHub Organization>/<GitHub Project> 10 --dry-run
Getting GitHub issue <GitHub Organization>/<GitHub Project>#10...
Got profile OK!
Got GitHub client.
Got repository: https://github.com/<GitHub Organization>/<GitHub Project>.
Got issue: https://github.com/<GitHub Organization>/<GitHub Project>/pull/10.
Updating existing issue, since --allow-existing was not set.
Not updating new work item in ADO, as --dry-run was set.

Updating

Simply pull the latest version of gh-sync and then run the install script again.

git pull
./install.ps1

gh-sync's People

Contributors

cgranade avatar israelmiles avatar microsoft-github-policy-service[bot] avatar scottcarda-ms avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gh-sync's Issues

The field 'State' contains the value 'New' that is not in the list of supported values

Hi I have gh-sync set up here:
https://github.com/microsoft/WSL/blob/master/.github/workflows/gh-sync.yml

I am seeing this issue when trying to run it:
Unhandled exception: Microsoft.TeamFoundation.WorkItemTracking.WebApi.RuleValidationException: The field 'State' contains the value 'New' that is not in the list of supported values, which isn't allowing us to sync issues.

Any idea on how to fix or resolve it?

Full code dump:

Getting GitHub issue microsoft/WSL#9169...
Got profile OK!
Got GitHub client.
Got repository: https://github.com/microsoft/WSL.
Got issue: https://github.com/microsoft/WSL/issues/9169.
Got profile OK!
Added 1 comments from GitHub issue.
Unhandled exception: Microsoft.TeamFoundation.WorkItemTracking.WebApi.RuleValidationException: The field 'State' contains the value 'New' that is not in the list of supported values
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync(HttpRequestMessage message, HttpCompletionOption completionOption, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpRequestMessage message, Object userState, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.SendAsync[T](HttpMethod method, IEnumerable`1 additionalHeaders, Guid locationId, Object routeValues, ApiResourceVersion version, HttpContent content, IEnumerable`1 queryParameters, Object userState, CancellationToken cancellationToken)
   at Microsoft.GhSync.Synchronizer.<>c__DisplayClass[12](https://github.com/microsoft/WSL/actions/runs/3527624557/jobs/5916928330#step:3:13)_0.<<UpdateState>b__0>d.MoveNext() in /app/src/GhSync/Services/Synchronizer.cs:line 57
--- End of stack trace from previous location ---
   at Microsoft.GhSync.Extensions.Bind[TResult,TNewResult](Task`1 task, Func`2 continuation) in /app/src/GhSync/Extensions/Extensions.cs:line 2[13](https://github.com/microsoft/WSL/actions/runs/3527624557/jobs/5916928330#step:3:14)
   at Microsoft.GhSync.Synchronizer.UpdateState(WorkItem workItem, Issue issue) in /app/src/GhSync/Services/Synchronizer.cs:line 55
   at Microsoft.GhSync.Synchronizer.PullGitHubIssue(Issue ghIssue, Boolean dryRun, Boolean allowExisting) in /app/src/GhSync/Services/Synchronizer.cs:line 42
   at Microsoft.GhSync.Program.<PullIssueCommand>b__3_0(String repo, Int32 issueId, Boolean dryRun, Boolean allowExisting) in /app/src/GhSync/Program.cs:line 61
   at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass18_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.GhSync.Program.<>c__DisplayClass8_0.<<Invoke>b__0>d.MoveNext() in /app/src/GhSync/Program.cs:line [17](https://github.com/microsoft/WSL/actions/runs/3527624557/jobs/5916928330#step:3:18)9
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass13_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass20_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__[19](https://github.com/microsoft/WSL/actions/runs/3527624557/jobs/5916928330#step:3:20)_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__6_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass9_0.<<UseExceptionHandler>b__0>d.MoveNext()

Thanks!

Bring gh-sync to level 2 maturity

Now that gh-syc is being used as a daily tool with its own private repository, it needs to comply with a higher security level. Specifically, gh-sync needs the following:

  • Getting started section of README
  • Intended usage (maturity level)
  • Building instructions
  • No secrets (passwords, tokens, ssh keys, etc) in code
  • Unittests
  • CI/PR builds (compile and test)
    Pull Requests required for main

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.