Gate deployments on successful CI from the main branch.

Section: Release and deployment workflows

Deploy only from main after tests

yaml
yaml
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: echo "run tests here"

  deploy:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: production
    steps:
      - run: ./scripts/deploy.sh
Explanation

This pattern keeps deployment logic explicit and easy to reason about.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Release and deployment workflows
Create a GitHub release on tag push
Publish a release whenever a version tag is pushed.
OpenIn sheetyamlsame section
Publish an npm package
Publish to npm from GitHub Actions.
OpenIn sheetyamlsame section
Node.js CI workflow
Install dependencies, lint, test, and build a Node project.
Python CI workflow
Set up Python, install dependencies, and run tests.
Build a Docker image
Use Buildx for modern Docker builds.