/TF-Automation

This my TF automation repo

MIT LicenseMIT

TF-Automation

Just a test repo for Task force project board creation

Note Make sure to create an error queue and a queue that is the name of your AzureWebJobsStorage inside of your AzureWebJobsServiceBus

Get asb-transport CLI

dotnet tool install -g NServiceBus.Transport.AzureServiceBus.CommandLine

Create the endpoint queue

Note Make sure to use the -c option if you want to override or do not have the AzureServiceBus_ConnectionString environment variable set.

asb-transport endpoint create <queue name>

Subscribe to events

asb-transport endpoint subscribe <queue name> <eventtype>

Using Altair GraphQL Client IDE

Configure Altair

  1. Get an access token
  2. Install and launch Altair
  3. In the left sidebar, below the Altair logo, click Set Headers. A new window will open.
  4. In the "Header key" field, enter Authorization.
  5. In the "Header value" field, enter Bearer TOKEN, replacing TOKEN with your token from the first step.
  6. In the "Header key" field, enter X-Github-Next-Global-ID.
  7. In the "Header value" field, enter 1
  8. Click Save in the bottom right corner of the window to save your authorization header.
  9. In the "GraphQL Endpoint" field, enter https://api.github.com/graphql.
  10. To load the GitHub GraphQL schema, download the public schema.
  11. In Altair, click on Docs on the top right, then the three dots and Load Schema...
  12. Select the file public schema that you downloaded in an earlier step.

Graphql Authentication CLI

Before running GitHub CLI commands, you must authenticate by running gh auth login --scopes "project". If you only need to read, but not edit, projects, you can provide the read:project scope instead of project. For more information on command line authentication, see "gh auth login."

legacy_global_id / next_global_id

legacy_global_id is is now deprecated, which typically looks like this MDQ6VXNlcjM0MDczMDM=. There is now a next_global_id that is being used that has a format like PVT_kwHOBTAVOs4ANTT3. By adding another header to the API call the new next_global_id can be retrieved.

Powershell

Instead of doing this command to get the node_id of an authenticated user

gh api -H "Accept: application/vnd.github+json" /users/{username}

Result

{
  "node_id": "MDQ6VXNlcjg3MDM3MjQy"
}

Add this to the API call to get the new next_global_id node_id

gh api -H "Accept: application/vnd.github+json" -H "X-Github-Next-Global-ID: 1" /users/{username}
{
  "node_id": "U_kgDOBTAVOg"
}

Creating projects

To create a new project using the API, you'll need to provide a name for the project and the node ID of a GitHub user or organization who will become the project's owner.

You can find the node ID of a GitHub user or organization if you know the username. Replace GITHUB_OWNER with the GitHub username of the new project owner. To create the project, replace OWNER_ID with the node ID of the new project owner and replace PROJECT_NAME with a name for the project.

To create the project, replace OWNER_ID with the node_id of the new project owner using the new next_global_id and replace PROJECT_NAME with a name for the project.

Powershell

When using powershell and doing a query or mutation make sure to escape the quotation marks " using a a backslash \ when indicating a String.

gh api graphql -H "X-Github-Next-Global-ID: 1" -f query='mutation{createProjectV2(input:{ownerId:\"U_kgDOBTAVOg\",title:\"TF-Project\"}){projectV2{id}}}'

Result

{
  "data": {
    "createProjectV2": {
      "projectV2": {
        "id": "PVT_kwHOBTAVOs4ANThR"
      }
    }
  }
}

Using the legacy_node_id

If you use the legacy_node_id, but include the X-Github-Next-Global-ID: 1 header then the project will get created, but a deprecation warning will show up letting you know that you should use next_global_id instead.

Powershell

gh api graphql -H "X-Github-Next-Global-ID: 1" -f query='mutation{createProjectV2(input:{ownerId:\"MDQ6VXNlcjg3MDM3MjQy\",title:\"TF-Project\"}){projectV2{id}}}'

Result

{
  "data": {
    "createProjectV2": {
      "projectV2": {
        "id": "PVT_kwHOBTAVOs4ANTjy"
      }
    }
  },
  "extensions": {
    "warnings": [
      {
        "type": "DEPRECATION",
        "message": "The id MDQ6VXNlcjg3MDM3MjQy is deprecated. Update your cache to use the next_global_id from the data payload.",
        "data": {
          "legacy_global_id": "MDQ6VXNlcjg3MDM3MjQy",
          "next_global_id": "U_kgDOBTAVOg"
        },
        "link": "https://docs.github.com"
      }
    ]
  }
}

Get node_id for project

Powershell

gh api graphql -H "X-Github-Next-Global-ID: 1" --raw-field query='query{ user(login:\"{username}\") { projectV2(number: 11) { id } } }'

Result

{
  "data": {
    "user": {
      "projectV2": {
        "id": "PVT_kwHOBTAVOs4ANTT3"
      }
    }
  }
}

Get node_id for issue

Powershell

gh api graphql -H "X-Github-Next-Global-ID: 1" --raw-field query='query{ repository(owner:\"TravisNickels\", name:\"TF-Automation\") { issue(number: 1) { id } } }'

Result

{
  "data": {
    "repository": {
      "issue": {
        "id": "I_kwDOJJR3y85mmxkx"
      }
    }
  }
}

Links

Note

Note test

Tip

Tip test

Important

Important test

Warning

Warning test

Caution

Caution test