Integrating GitHub Repositories with Azure Pipelines
This lesson explains how to connect the two, and how authentication options differ.
Learning outcomes
After completing this lesson, you will be able to:
- Compare GitHub App, OAuth and personal access token connections.
- Describe the setup of a pipeline for a GitHub repository.
- Require a pipeline as a status check.
- Explain how fork builds are protected.
Why integrate
Organizations often reach this design while moving code to GitHub without wanting to rewrite pipelines and environments immediately. Azure Pipelines keeps its stages, checks and deployment history, while GitHub becomes the place for code and pull requests. Azure Pipelines also supports specialized needs, such as existing service connections and Azure DevOps Server agents.
Authentication options
Azure Pipelines needs permission to read a repository and report statuses. There are three ways to provide it, and each makes a pipeline run as a different identity.
GitHub App
The Azure Pipelines app, installed from GitHub Marketplace, is the recommended option. The app's identity is used for CI and pull request integration, so nobody's personal account is involved, and it keeps working when an employee leaves. It uses the Checks API, which shows detailed results within a pull request, and allows re-running a failed check from GitHub. Selected repositories can be chosen when installing, and it requires organization owner approval.
OAuth
An OAuth connection authorizes Azure Pipelines to act as a specific GitHub user. It is quick to set up, but it is tied to that person, and statuses appear under their name.
Personal access token
A PAT connection also uses one person's token, with the repo, admin:repo_hook, read:user and user:email scopes for classic tokens. It needs manual rotation, so it is the least attractive option.
The following diagram compares three ways of connecting Azure Pipelines to 80 GitHub repositories.

GitHub App, OAuth or PAT?
Setting up a pipeline
-
Install the app
A GitHub organization owner installs Azure Pipelines from GitHub Marketplace and selects repositories.
-
Create a pipeline
In Azure Pipelines, select New pipeline, choose GitHub, and pick the repository.
-
Commit the YAML
The wizard adds azure-pipelines.yml to the GitHub repository, through a commit or pull request.
-
Check triggers
CI and pr triggers now work from GitHub events, because the app registers for them.
-
Require the check
In GitHub branch protection or a ruleset, make the pipeline a required status check.
Note that the pr keyword does work here. Azure Repos is the exception, and GitHub is not, so a YAML file with both trigger and pr is normal for a GitHub repository.
Building a GitHub repository in Azure Pipelines
Security with forks
Pull requests from forks present a risk, because their code is untrusted, yet the pipeline would run it. By default, Azure Pipelines does not make secrets available to fork builds, and a repository setting controls whether to build forks at all. Fork builds can also be required to wait for a comment from a team member. A self-hosted agent should not run untrusted pull request code, since that code would run on your machine and potentially inside your network.
Other details also matter. Status badges in a README show a pipeline's state. A pipeline can link commits to Azure Boards work items, through the Azure Boards app and AB# syntax. For a monorepo, path filters work the same way as they do for Azure Repos.
Building pull requests from forks
Choosing the connection
A company has moved 80 repositories from Azure Repos to a GitHub organization. Its Azure Pipelines definitions must keep running, and the pipelines must keep working when individuals leave. Developers want to see detailed test results within GitHub pull requests. Which connection should you use?
You should install the Azure Pipelines GitHub App in the organization. It does not depend on a person, and its use of the Checks API shows detailed results in the pull request. OAuth and personal access tokens are both tied to a user, and they would break when that person leaves. Converting all pipelines to GitHub Actions is a larger project than the requirement needs.
Does the pr keyword work for a GitHub repository in Azure Pipelines?
Show answer
Yes. Only Azure Repos ignores it, and that platform uses build validation instead.
Exam Tips
Remember for the exam
- The Azure Pipelines GitHub App is the recommended connection.
- OAuth and personal access tokens are tied to a user.
- The GitHub App reports through the Checks API.
- The pr keyword works for GitHub repositories.
- Secrets are withheld from fork builds by default.