Pipelines
Deploy
Build on every push and deploy to stage from the stage branch and to production from main, one deploy per environment at a time.
Available in repositories branchd reads pipeline files for. It is switching repositories on one at a time: until yours is, it keeps running its
.forge-ci.yamlor.xeonr-ci.yaml. See What is available.
# .branchd/pipelines/ci.yaml
# Build on every push, deploy to stage from the stage branch and to
# production from main. One deploy per environment runs at a time.
name: CI
on:
push:
branches: [main, stage]
jobs:
build:
image: golang:1.26
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- run: go build -o dist/server ./cmd/server
- id: version
run: echo "version=$CI_COMMIT_SHORT_SHA" >> "$BRANCHD_OUTPUT"
artifacts: [dist]
deploy:
needs: [build]
if: branch == 'main' || branch == 'stage'
image: alpine:3
environment:
name: ${{ branch == 'main' && 'production' || 'stage' }}
url: ${{ branch == 'main' && 'https://app.example.com' || 'https://stage.app.example.com' }}
concurrency: deploy-${{ branch }}
secrets: [DEPLOY_TOKEN]
steps:
- run: ./scripts/deploy.sh "${{ branch }}" "${{ needs.build.outputs.version }}"
- One deploy job for two environments.
&&and||return one of their operands, so${{ branch == 'main' && 'production' || 'stage' }}isproductiononmainandstageelsewhere. environment:records a deployment of that name, with itsurl, on each run of the job.concurrency: deploy-${{ branch }}is a lock: one job holdingdeploy-mainruns at a time in this repository, and the next waits. Two runs never deploy one environment at once.secrets: [DEPLOY_TOKEN]grants the job the secret, as the environment variable$DEPLOY_TOKEN. See Secrets.- Outputs and artifacts.
deployreadsbuild'sversionoutput, and findsbuild'sdist/(its artifacts) in its working directory.
To make a person release the production deploy, see Environments and manual approval.