GitHub Actions and CI
Hold a deploy or any CI step until a person approves it, from GitHub Actions or any pipeline that runs a shell.
A pipeline is an agent too: it deploys, migrates and publishes without anyone watching. One step that asks first makes the risky ones wait for a person, who can answer from a phone.
1. Create a key for CI
- Create an agent key under Agents, named after the pipeline.
- In GitHub, open Settings, Secrets and variables, Actions, and add it as
VARIANTGATE_KEY.
2. Add the approval step
This step asks, waits for the answer, and fails the job unless the answer is a yes. It needs only curl and jq, which GitHub runners have.
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- name: Wait for a person to approve
env:
VARIANTGATE_KEY: ${{ secrets.VARIANTGATE_KEY }}
run: |
ANSWER=$(curl -fsS -X POST https://api.variantgate.com/v1/requests \
-H "authorization: Bearer $VARIANTGATE_KEY" \
-H 'content-type: application/json' \
-d "{\"agent\":\"ci\",\"action\":\"deploy.production\",\"summary\":\"Deploy ${{ github.sha }} to production\",\"wait_seconds\":30}")
ID=$(echo "$ANSWER" | jq -r .id)
while [ "$(echo "$ANSWER" | jq -r .status)" = "pending" ]; do
ANSWER=$(curl -fsS "https://api.variantgate.com/v1/requests/$ID?wait_seconds=30" \
-H "authorization: Bearer $VARIANTGATE_KEY")
done
[ "$(echo "$ANSWER" | jq -r .allowed)" = "true" ] || { echo "Not approved"; exit 1; }
- name: Deploy
run: ./deploy.sh- Each check holds the call open for up to 30 seconds, so the loop calls about twice a minute while it waits.
- The request expires after 15 minutes unless you add
ttl_seconds; then the step fails. Keep the job’stimeout-minuteslonger than the request’s time limit. curl -ffails the step on any error from the API, so a problem stops the deploy instead of letting it through.
3. Run it
Start the workflow. The request appears in the inbox with the commit in its summary; approve it and the deploy runs.
With the command line
variantgate run does the same in one line, runs the command only on a yes, and reports whether it succeeded so the record shows the result.
- name: Deploy once a person approves
env:
VARIANTGATE_API_URL: https://api.variantgate.com
VARIANTGATE_KEY: ${{ secrets.VARIANTGATE_KEY }}
run: npx -y https://variantgate.com/sdk/variantgate-agent-latest.tgz run --agent ci --action deploy.production --summary "Deploy ${{ github.sha }}" -- ./deploy.shThe step downloads the variantgate command from variantgate.com, so the runner needs nothing installed beyond Node.
Other pipelines
The shell step works in any CI that runs a shell: GitLab, CircleCI, Jenkins, Buildkite. Store the key as a masked secret and run the same lines before the step that needs a yes.
Compared with deployment environments
GitHub’s required reviewers for environments also hold a job for a person. Use this instead when the decision belongs with your agents’ decisions: one inbox, the same rules and emergency stop, and one record for everything that acted on your behalf.