How to wire a repository into GitHub Actions
Take a repository that already contains the toolchain and make its workflows run on GitHub. This is the GitHub counterpart of how to wire a repository into Bitbucket Pipelines. For the branch/environment reasoning behind these steps, see the branch, environment and org model.
You need repository admin rights for the steps below. The workflows use no GitHub environments and therefore no deployment protection rules, so they run on any plan; on GitHub Enterprise the rules exist but stay unused.
Restrict the actions and the default token
In Settings → Actions → General, set:
- Actions permissions: "Allow
, and select non- , actions and reusable workflows", with only "Allow actions created by GitHub" ticked - Require actions to be pinned to a full-length commit SHA: ticked
- Workflow permissions: "Read repository contents and packages permissions"
- Allow GitHub Actions to create and approve pull requests: unticked
The workflows declare their own permissions: per job (see the
GitHub workflows reference), so the read-only
default changes nothing for them.
Allow merge commits only
In Settings → General → Pull Requests, allow merge commits and untick squash and rebase.
Squash and rebase merges disable quick deploys — see delta deployments and quick deploys.
Protect main
In Settings → Rules → Rulesets → New branch ruleset, target main and enable:
- Require a pull request before merging, with at least one approval
- Block force pushes
- Restrict deletions
- optionally, Allowed merge methods limited to merge
Do not create GitHub environments; the workflows use none. A merge into main deploys to
production, so the approvals above are the release gate — why that is so is in
the branch, environment and org model.
Set the secrets
In Settings → Secrets and variables → Actions → Secrets, add these repository secrets. Follow how to authenticate CI to an org to export each auth URL on your own machine and store it.
DEVHUB_AUTH_URL<ENV>_AUTH_URLfor every environment name of the branch map —SIT_AUTH_URL,UAT_AUTH_URL,PRODUCTION_AUTH_URLwith the default mapBASE64_BOT_PRIVATE_KEY— optional, only when the write-back branch is protected; register it as a deploy key with write access and give it a ruleset bypass
Enable deployments
In the Variables tab of the same page, add the repository variable:
Without it, deploy steps run as a dry run — see the environment variable reference for the exact behavior.
Use the same variable names as on Bitbucket; the environment variable reference describes how they reach the toolchain on GitHub.
Map branches to environments
The default map in env.mjs is:
| Branch | Environment |
|---|---|
integration, develop |
sit |
uat |
uat |
master, main, trunk |
production |
| pull request into any other | sit |
The template declares this map explicitly in sfdx-project.json under
plugins.diadx.branchEnvironments with pullRequestFallbackEnvironment. Edit it when your
branches differ; the environment name is the auth-URL prefix and the stage name of the opt-ins
(exact format in the
environment variable reference).
The trigger workflows (push-*.yml, pull-request.yml) are the per-repository part and name the
branches; edit their branches: lists to match your map. The reusable _*.yml workflows and the
setup-toolchain composite action are shared with the template and stay untouched. See the
workflow reference for which workflow does what.
Set the optional opt-ins
None of the following are required for a first run. Set them as repository variables:
- Delta deployments per stage,
DELTA_DEPLOY_<STAGE>— how to enable delta deployments for a stage - Pooled scratch-org validation on pull requests,
SCRATCH_ORG_VALIDATION_<STAGE>— how to validate a PR against a scratch org - Test level for delta deployments,
DELTA_TEST_LEVEL - REST metadata deploy,
SF_ORG_METADATA_REST_DEPLOY, for deployments above the SOAP size limit
The full variable set is in the environment variable reference.
Scheduled workflows run on the default branch only
code-analyzer-baseline.yml checks out develop explicitly; dispatch it with another
branch input when the baseline belongs elsewhere.
Push and watch the first run
Push a feature branch. Push Feature runs Validate and needs no secrets at all. Then open a pull
request into develop: it runs Scan Secrets, then Validate against Scratch (self-gated, a no-op
until its opt-in is set), then Validate against Org. Open the Actions tab to watch the runs.
Confirm before merging pull requests
Validate against Org runs unconditionally on the pull request, confirming the auth URL for that stage resolves correctly, even with no opt-ins set.
deploy-production.yml is a re-deploy tool, not the release: dispatch it from main and name the
commit SHA explicitly. The Bitbucket counterpart is described in the
pipeline reference.