Skip to content

Instantly share code, notes, and snippets.

@DannyDainton
Created June 10, 2024 14:47
Show Gist options
  • Save DannyDainton/35b180cf06023323fad67dce013409c0 to your computer and use it in GitHub Desktop.
Save DannyDainton/35b180cf06023323fad67dce013409c0 to your computer and use it in GitHub Desktop.
A basic workflow file that can be used to run your Postman Collection through a GitHub Action using specific configurations. The result are presented in the GitHub Action console and also on the runs section of the Postman Collection.
name: Automated API tests using Postman CLI
run-name: The Collection run was started by ${{ github.actor }}
on:
workflow_dispatch:
inputs:
collection-uid:
required: true
type: string
description: 'The Collection UID for the run'
iterations:
description: 'Number of iterations to run'
required: false
type: string
use-verbose-output:
type: boolean
description: Include the detailed request and response data
jobs:
automated-api-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Postman CLI
run: |
curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
- name: Login to Postman CLI
run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}
- name: Run API tests
run: |
postman collection run ${{ inputs.collection-uid }} -n ${{ inputs.iterations || 1 }} ${{inputs.use-verbose-output && '--verbose' || ''}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment