Automate Native Git with CI/CD
Automate Native Git with CI/CD
Rather than pushing and pulling changes manually, automate the synchronization process using the Postman CLI push command within a CI/CD pipeline, triggered by events like merging a pull request.
Add a GitHub workflow to publish to Postman Cloud
-
Set up your CI/CD Secret. To generate an API Key, create a Postman API key from your Postman account settings. Add this key as a protected secret (for example,
POSTMAN_API_KEY) in your repository’s settings (for example, GitHub Secrets, GitLab Variables). -
Add the synchronization step to your pipeline. The primary command recommended for this workflow is
postman workspace push. This command validates and synchronizes your local files with the cloud workspace.
Example: GitHub Actions workflow
Create or update your .github/workflows/postman-publish.yml file with the following steps:
Recommended best practices
-
Use the
--yesflag: In a CI/CD environment, use the-yor--yesoption to skip manual confirmation prompts. -
Lint before pushing: Add lint steps before
postman workspace pushso invalid files are caught before they reach the cloud. You can lint collections, environments, and global variables. -
Validation: The push command automatically runs a prepare step that checks and fixes entity IDs, such as UUIDs, before syncing. Prepare doesn’t validate the file format, so lint your files first to catch invalid YAML, structure, and schema issues.
Merge and validate your integration
To complete your setup, do the following:
- Commit the Postman files + GitHub workflow and push your branch.
- Create a PR to
developand merge it. - Trigger a release to
main.