Moving from GitHub Actions
A GitStack repository mirrored to GitHub can gate landing on GitHub Actions. This page moves it to Buildkite instead: what replaces each part of a workflow, a converted example, and an order of changes that keeps a required check in place at every step.
The split is the same as on GitHub. GitStack sends the events, gates landing on the results and issues the repository's token. Buildkite runs the jobs on your agents and holds the pipeline and its secrets. If your builder isn't Buildkite, the same plan works with CI with any builder.
What replaces what#
| GitHub Actions | On GitStack with Buildkite |
|---|---|
on: pull_request |
A review's commit builds when a land needs its checks, when someone presses Run checks, or with gs review ci. Pushing a review starts nothing. GITSTACK_EVENT is review. |
on: push to the default branch |
The default branch builds after every land, with no setting. GITSTACK_EVENT is main. |
on: push with branches |
branches under [ci] in .gitstack/policy.toml. GITSTACK_EVENT is push. |
on: push with tags |
tags under [ci]. Only new tags build, since a tag never moves. GITSTACK_EVENT is tag. |
on: schedule |
A Buildkite pipeline schedule. Scheduled builds show in Buildkite only: they never gate a land or start an auto-revert. |
on: workflow_dispatch |
New Build in Buildkite, or its API. |
| A job, and the check name branch protection requires | A step with a key, reported as <pipeline>/<key> and required as buildkite:<pipeline>/<key> under [checks]. |
needs: |
A wait step or depends_on in the pipeline. |
if: startsWith(github.ref, 'refs/tags/') |
if: build.env("GITSTACK_EVENT") == "tag". A tag build's branch is the tag's name, and Buildkite's own build.tag is empty. |
github.sha, github.ref, github.event_name |
BUILDKITE_COMMIT, GITSTACK_REF, GITSTACK_EVENT. GITSTACK_REPO, GITSTACK_REVIEW and GITSTACK_STACK name the repository, review and branch. |
runs-on |
The agent queue a step runs on (agents: queue:), on Buildkite's hosted agents or your own. |
actions/checkout |
The agent clones the pipeline's repository URL, the GitStack clone URL, with the integration's token as the git password. On hosted agents the token is a Buildkite secret (see Set it up). |
secrets.* |
Your agents' secrets. GitStack never sees them and puts none of its own in a build. |
GITHUB_TOKEN with contents: write, to push tags |
The token's tags right. It creates tags on landed commits and never moves or deletes one. A tag GitStack makes is pushed to the GitHub mirror too. |
GITHUB_TOKEN with contents: write, to push branches |
The token's branches right, limited to the patterns you give it. Never the default branch or a review branch. |
GITHUB_TOKEN with pull-requests: write, to comment |
The token's comment right: a review comment shown as the integration with a bot label. |
checks: write, statuses: write |
Not needed: Buildkite reports its builds to GitStack itself. A builder without a connector posts checks with the checks right. |
| Re-run failed jobs | Run checks or gs review ci retries the failed jobs of a failed build. Retrying a job in Buildkite works too. |
concurrency with cancel-in-progress, on the default branch |
A land cancels the default branch's older builds that still run, and never one auto-revert is using. Leave Buildkite's Cancel intermediate builds off. |
A step named Setup: ..., so auto-revert reads its failure as setup |
Exit status 75 from the step's setup commands (see When the default branch goes red). |
| A red default branch, reverted by hand | on_red = "revert" under [landing], the default: GitStack retries the failed jobs once, then reverts the land that broke the branch. |
| The GitHub mirror | Optional. Buildkite builds from GitStack directly. |
on: pull_requestgs review ci. Pushing a review starts nothing. GITSTACK_EVENT is review.on: push to the default branchGITSTACK_EVENT is main.on: push with branchesbranches under [ci] in .gitstack/policy.toml. GITSTACK_EVENT is push.on: push with tagstags under [ci]. Only new tags build, since a tag never moves. GITSTACK_EVENT is tag.on: scheduleon: workflow_dispatchkey, reported as <pipeline>/<key> and required as buildkite:<pipeline>/<key> under [checks].needs:wait step or depends_on in the pipeline.if: startsWith(github.ref, 'refs/tags/')if: build.env("GITSTACK_EVENT") == "tag". A tag build's branch is the tag's name, and Buildkite's own build.tag is empty.github.sha, github.ref, github.event_nameBUILDKITE_COMMIT, GITSTACK_REF, GITSTACK_EVENT. GITSTACK_REPO, GITSTACK_REVIEW and GITSTACK_STACK name the repository, review and branch.runs-onagents: queue:), on Buildkite's hosted agents or your own.actions/checkoutsecrets.*GITHUB_TOKEN with contents: write, to push tagstags right. It creates tags on landed commits and never moves or deletes one. A tag GitStack makes is pushed to the GitHub mirror too.GITHUB_TOKEN with contents: write, to push branchesbranches right, limited to the patterns you give it. Never the default branch or a review branch.GITHUB_TOKEN with pull-requests: write, to commentcomment right: a review comment shown as the integration with a bot label.checks: write, statuses: writechecks right.gs review ci retries the failed jobs of a failed build. Retrying a job in Buildkite works too.concurrency with cancel-in-progress, on the default branchSetup: ..., so auto-revert reads its failure as setup75 from the step's setup commands (see When the default branch goes red).on_red = "revert" under [landing], the default: GitStack retries the failed jobs once, then reverts the land that broke the branch.The token's rights are set when you make it, in the repository's Settings, CI checks. See Writing back from a build.
A worked example#
A typical workflow lints and tests every pull request and every push to
main, and publishes a release for each v* tag:
# .github/workflows/ci.yml
name: ci
on:
pull_request:
push:
branches: [main]
tags: ["v*"]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make test
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make release
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
Its landing policy requires the two jobs by their GitHub check names:
# .gitstack/policy.toml, before
[checks]
required = ["lint", "test"]
In Buildkite, with a pipeline named api, the same work is one file. The
checkout is the agent's, and REGISTRY_TOKEN comes from the agent's
secrets rather than the file:
# .buildkite/pipeline.yml
steps:
- label: "Lint"
key: lint
command: make lint
- label: "Test"
key: test
command: make test
- wait
- label: "Release"
key: release
if: build.env("GITSTACK_EVENT") == "tag"
command: make release
The policy requires the Buildkite steps and builds v* tags. Reviews and
the default branch need no entry, since GitStack builds them on its own:
# .gitstack/policy.toml, after
[checks]
required = ["buildkite:api/lint", "buildkite:api/test"]
[ci]
tags = ["v*"]
Switch over without a gap#
Each policy change below lands as a review, and the policy that applies to a land is the one already on the default branch. Every land along the way is gated by at least one CI.
-
Connect Buildkite. Land
.buildkite/pipeline.yml, then create the pipeline and connect it as in Quickstart: CI with Buildkite, steps 1 to 6. GitHub Actions still gates landing. -
Require both. Add the Buildkite checks beside the GitHub ones:
toml[checks] required = ["lint", "test", "buildkite:api/lint", "buildkite:api/test"]Each land now waits for both, so you can compare the two on the same changes. A land asks Buildkite to build any commit it hasn't built yet.
-
Require only Buildkite. Once the Buildkite checks have passed and failed where GitHub's did, drop the GitHub names:
toml[checks] required = ["buildkite:api/lint", "buildkite:api/test"] [ci] tags = ["v*"]Add
[ci]entries for any branch or tag pushes the workflows built. If[checks]has adispatchworkflow, remove it in the same change. -
Remove the workflows. Delete the files under
.github/workflowsin a review. GitHub stops running them once the mirror receives the change. -
Remove the GitHub mirror, if you don't need it. Keep it if anything else reads the GitHub copy. Otherwise, in the repository's Settings, GitHub, choose Remove mirror. GitStack stops pushing to GitHub and stops importing its pull requests and issues; nothing on GitHub changes. Two things have to go first, and the section lists each one before you press the button:
- Branches under
github_managedin[mirror]. GitHub owns them, so remove them from the list in a review first. - Open reviews made from GitHub pull requests. Merge or close each pull request on GitHub, or abandon the review.
If the policy still requires a check only GitHub reports, the confirm names it: lands that require it are refused until you change the policy, which step 3 already did. Owners can also remove the mirror with
DELETE /api/v1/repos/<namespace>/<name>/mirror/github, and mirror the repository again later withgs repo mirror-github. - Branches under
What doesn't carry over#
- Marketplace actions. A
uses:step has no Buildkite equivalent. Replace it with the command it wraps, a script in the repository, or a Buildkite plugin. - GitHub Releases, GitHub Packages and the GitHub Container Registry. These are GitHub's hosting, not CI. The release step publishes wherever the repository chooses: a container registry, a package index, a file store.
- Caches and artifacts from
actions/cacheandactions/upload-artifact. Use Buildkite's artifacts and your agents' own caches. - Environments and deployment approvals. Use Buildkite's block steps and its own permissions.