Integrate Postman with GitHub Actions

GitHub Actions self-hosted runners are available on Postman Enterprise Ultimate plans.

GitHub Actions is a continuous integration and continuous delivery (CI/CD) service that's integrated with GitHub. Software development teams can use GitHub Actions to automatically build, test, and deploy code in GitHub.

To set up a GitHub Actions integration for your API, first create a pipeline in GitHub and then configure your API in Postman. After you set up the integration, you can view the status of builds from within Postman.

Creating a pipeline in GitHub

If you haven't already, create a pipeline in the GitHub repository you use for your API. To create a pipeline, create a directory in your repository named .github/workflows, and then add a YAML file to the directory. You define your pipeline in this YAML file. To learn more, see the GitHub Actions documentation.

Configuring a GitHub Actions integration

  1. Open your API by selecting APIs in the sidebar. Each API can be linked to one CI project.

    Tip: If you've already authenticated with GitHub to connect a Git repo for source control, you can use the same authentication. To automatically create the integration, under Test and Automation, select Connect to GitHub.

  2. Select Test and Automation.

  3. Under Automate, select GitHub Actions.

  4. You'll be prompted to allow Postman to access your GitHub account. After you grant access, you can close the browser tab and return to Postman.

    There's a limit of ten auth tokens per user per application imposed by GitHub. If you create more than ten connections with the same user, the additional tokens will be revoked in the order that they were created. Teams can use other Postman accounts to create more than ten integrations.

  5. Enter a Nickname to help you recognize the integration later. Postman pre-fills a nickname in the format GitHub-{API_NAME}, and you can edit it if you want.

  6. Select the GitHub Organization with your API repository.

  7. Select the Repository used for your API.

  8. Select Connect.

Connect to GitHub Actions

Viewing build status

After you set up a GitHub Actions integration, information for build jobs is available in Postman. For each build you can view the branch, start time, and status (Success or Failure). You can also view the results of collection runs that are configured in your pipeline using the Postman CLI.

To view build jobs, open an API and select Test and Automation. The most recent jobs are listed under the repository name.

You can't start GitHub Actions builds directly in Postman. To start a new build, go to GitHub.

Select View All Builds to view the full list of build jobs. From here you can take the following actions:

  • Use the dropdown lists to filter jobs by branch or build status.
  • To open a build in GitHub, select the build name.
  • To get the latest build status information, select Refresh icon Refresh.
  • To edit or delete the integration, select the more actions icon More actions icon.
View all GitHub builds

Viewing collection run details

Using the Postman CLI, you can run Postman collections with your API tests as part of a GitHub Actions pipeline.

To view details for collections that were run as part of a build, first configure the Postman CLI for GitHub and then start a new build in GitHub. To learn more about starting builds, see the GitHub Actions documentation. After the build is complete, use the arrows to expand a build and expand a collection to view details about a collection run.

Select View Report to view a collection run report in the Postman History. Learn more about using the Collection Runner.

Viewing API Governance and API Security rule violations

Using the Postman CLI, you can enforce Postman API Governance and API Security rules each time the pipeline runs using the api lint command (Enterprise teams only).

To view the results of API Governance and API Security checks that ran as part of the build, first configure the Postman CLI for GitHub Actions and then start a new build on GitHub. After the build is complete, use the arrows to expand a build and expand an API definition to view any rule violations.

View API Governance and API Security results

Configuring the Postman CLI for GitHub Actions

With the help of the Postman CLI and the Postman API, you can run Postman collections with your API tests as part of your GitHub pipeline. First generate the Postman CLI configuration code in Postman. Then add the configuration code to a YAML file in the .github/workflows directory in your GitHub repository.

Each time the pipeline runs, the Postman CLI runs the collections that contain your tests. You can view the results of your tests in Postman. You an also enforce API Governance and API Security rules each time the pipeline runs (Enterprise teams only).

Before you begin, make sure you’ve already set up an integration between your API and GitHub Actions.

To generate configuration code for the Postman CLI, do the following:

  1. Open your API and select Test and Automation.

  2. Under the repository name, select View All Builds.

  3. Select Configure Postman CLI.

  4. Select a Collection to run during pipeline builds. To be available in the list, you must first add the collection as a test suite to your API. You can also select an Environment to use.

  5. (Optional) Select the checkbox to enforce API Governance and API Security rules each time the CI/CD pipeline runs (Enterprise teams only).

  6. Select the Operating system for your CI/CD pipeline.

  7. Select Copy Postman CLI Command to copy the Postman CLI configuration.

    Generate the Postman CLI configuration

To add the Postman CLI configuration to your GitHub pipeline, do the following:

  1. Create a new YAML file in the .github/workflows directory in your GitHub repository, and then edit the file.
  2. Add the Postman CLI configuration you copied from Postman to the YAML file:

    Postman recommends that you store your Postman API key as a secret in GitHub to keep it secure. To learn more about secrets, see the GitHub documentation.

  3. Commit and push the changes to your remote repository. This will automatically start a build in GitHub.
  4. To view the test results in Postman, open your API and select Test and Automation. Learn more about Viewing collection run details.

Last modified: 2022/08/11