Deploy staging on every push, across repositories

Let a push to staging start a chain of GitHub Actions deployments, so the services that depend on the change are redeployed after it, in order, instead of drifting.

2 min readAuto-startStagingCI/CD

One push, several repositories

A push to staging redeploys the repository that changed. But if the web app and the mobile gateway depend on the API, staging is only really up to date once they have been deployed after it, in order. Doing that by hand is the step everyone forgets.

How auto-start works

Turn on Auto-start for a flow and it also starts when one of its first workflows runs outside Kodmos: a push that triggers api/deploy.yml, or someone pressing Run workflow on GitHub. Kodmos attaches to that GitHub run, waits for it to finish, and continues the chain from there.

  • Only the part of the flow downstream of that trigger runs.
  • The trigger’s branch must match the branch on the box, so a push to staging starts the staging flow and not the production one.
  • Runs that Kodmos dispatched itself never auto-start other flows, so two flows cannot trigger each other in a loop.

The workflow keeps its push trigger, and keeps workflow_dispatch so Kodmos can also start it as part of a release. On a push there are no inputs, so give the environment a fallback.

.github/workflows/deploy.yml
name: Deploy
on:
  push:
    branches: [staging]
  workflow_dispatch:
    inputs:
      environment:
        type: choice
        options: [Test, Production]
        required: true

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment || 'Test' }}
    steps:
      - uses: actions/checkout@v4
      - run: ./scripts/deploy.sh "${{ inputs.environment || 'Test' }}"

Start from the production flow

The staging flow is usually the production one pointed at other branches. Duplicate copies a flow without its run history and opens the copy in the editor: switch each box to the staging branch and the environment input to Test.

Watch it run

A push to staging ran the API workflow; Kodmos attached to it and carried on with the web app.

Each box shows its GitHub run as it happens: queued, waiting for approval, running, done. When a flow run fails outside a release, DevOps gets an email about it.

Every flow with its latest deploy: a red step anywhere is hard to miss.Every flow with its latest deploy: a red step anywhere is hard to miss.
Every flow with its latest deploy: a red step anywhere is hard to miss.

Try it on your next release.

Connect your GitHub organization, invite your team, and put the next release day on the calendar.