Creates Deployment Environments
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| name | string | - | |
| token | string | The token to use for authorization to GitHub | |
| repoUrl | string | Accepts the format `github.com?repo=reponame&owner=owner` where `reponame` is the new repository name and `owner` is an organization or username | |
| secrets | object | - | |
| reviewers | array | Reviewers for this environment. Must be a list of Backstage entity references. | |
| waitTimer | number | The time to wait before creating or updating the environment (in milliseconds) | |
| preventSelfReview | boolean | Whether to prevent self-review for this environment | |
| customTagPolicyNames | array | - | |
| environmentVariables | object | - | |
| deploymentBranchPolicy | object | - | |
| customBranchPolicyNames | array | - |
Output Schema
Usage Examples
Create a staging environment with variables and secrets
Creates a staging environment in a repository with environment variables and encrypted secrets. Use this after the repo exists, typically following publish:github.
steps:
- id: fetch-base
action: fetch:template
input:
url: ./skeleton
values:
repoName: ${{ parameters.repoName }}
owner: ${{ parameters.owner }}
- id: create-staging-environment
action: github:environment:create
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
name: staging
environmentVariables:
NODE_ENV: staging
LOG_LEVEL: info
FEATURE_FLAGS: enable-x,disable-y
secrets:
STAGING_API_KEY: ${{ parameters.stagingApiKey }}
DOCKER_REGISTRY_PASSWORD: ${{ parameters.dockerRegistryPassword }}
token: ${{ parameters.githubToken }}Create a production environment with required reviewers
Creates a production environment that requires review and prevents self review. Add a short wait to avoid race conditions right after repository creation with publish:github.
steps:
- id: fetch-base
action: fetch:template
input:
url: ./skeleton
values:
repoName: ${{ parameters.repoName }}
owner: ${{ parameters.owner }}
- id: create-production-environment
action: github:environment:create
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
name: production
preventSelfReview: true
reviewers:
- group:default/release-managers
- user:default/jlee
waitTimer: 5000
token: ${{ parameters.githubToken }}Create a preview environment with custom branch and tag policies
Creates a preview environment that uses named custom branch and tag policies configured in your GitHub organization. Use this to restrict deployments to specific branch or tag policies.
steps:
- id: fetch-base
action: fetch:template
input:
url: ./skeleton
values:
repoName: ${{ parameters.repoName }}
owner: ${{ parameters.owner }}
- id: create-preview-environment
action: github:environment:create
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
name: preview
customBranchPolicyNames:
- preview-branches
- rc-only
customTagPolicyNames:
- release-tags-only
token: ${{ parameters.githubToken }}Create an ephemeral PR environment
Creates an ephemeral environment named with a pull request number. Use this in templates that scaffold per PR resources for testing.
steps:
- id: fetch-base
action: fetch:template
input:
url: ./skeleton
values:
repoName: ${{ parameters.repoName }}
owner: ${{ parameters.owner }}
prNumber: ${{ parameters.prNumber }}
- id: create-ephemeral-pr-environment
action: github:environment:create
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
name: pr-${{ parameters.prNumber }}
environmentVariables:
PR_NUMBER: "${{ parameters.prNumber }}"
NODE_ENV: test
secrets:
TESTING_TOKEN: ${{ parameters.testingToken }}
token: ${{ parameters.githubToken }}Create a blue environment for blue green deployments
Creates a blue environment with custom tag policy names and minimal configuration. Use this alongside a green environment created in another step.
steps:
- id: fetch-base
action: fetch:template
input:
url: ./skeleton
values:
repoName: ${{ parameters.repoName }}
owner: ${{ parameters.owner }}
- id: create-blue-environment
action: github:environment:create
input:
repoUrl: github.com?repo=${{ parameters.repoName }}&owner=${{ parameters.owner }}
name: blue
customTagPolicyNames:
- stable-releases
secrets:
BLUE_API_TOKEN: ${{ parameters.blueApiToken }}
token: ${{ parameters.githubToken }}