> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Automate Native Git with CI/CD

Rather than [pushing and pulling changes manually](/docs/use/native-git/collaborate/#push-and-pull-changes-in-postman), automate the synchronization process using the [Postman CLI push command](/docs/postman-cli/postman-cli-workspace#postman-workspace-push) within a CI/CD pipeline, triggered by events like merging a pull request.

## Add a GitHub workflow to publish to Postman Cloud

1. Set up your CI/CD Secret. To generate an API Key, create a Postman API key from your [Postman account settings](https://go.postman.co/settings/me/api-keys). Add this key as a protected secret (for example, `POSTMAN_API_KEY`) in your repository’s settings (for example, GitHub Secrets, GitLab Variables).

2. 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:

```yaml
name: Publish changes to Postman
on:
  push:
    branches:
      - main  # Trigger sync when code is merged to main

jobs:
  publish-changes:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Postman CLI
        run: |
          curl -o- "https://dl-cli.pstmn.io/install/unix.sh" | sh

      - name: Verify Postman CLI version
        run: postman --version
      - name: Login to Postman
        run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}
      - name: Publish changes to Cloud
        run: postman workspace push -y
```

### Recommended best practices

* **Use the `--yes` flag:** In a CI/CD environment, use the `-y` or `--yes` option to skip manual confirmation prompts.

* **Lint before pushing:** Add lint steps before `postman workspace push` so invalid files are caught before they reach the cloud. You can lint [collections](/docs/postman-cli/postman-cli-collections/#postman-collection-lint), [environments](/docs/postman-cli/postman-cli-environments/#postman-environment-lint), and [global variables](/docs/postman-cli/postman-cli-globals/#postman-globals-lint).

* **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:

1. Commit the Postman files + GitHub workflow and push your branch.
2. Create a PR to `develop` and merge it.
3. Trigger a release to `main`.