Your graphcdn.yml
can define "environments", which is most useful to have different services for staging and production.
Basics
Use the environments
key in your graphcdn.yml
to define the different "environments" of your API:
# Defaults when --env is not specified
name: todo-api-prod
schema: https://todo.app/api
originUrl: https://todo.app/api
rules: ...
environments:
staging:
# Use a separate service for staging that points to the staging schema and origin
name: todo-api-staging
schema: https://staging.todo.app/api
originUrl: https://staging.todo.app/api
You can then push your configuration to the different environments with the --env
CLI flag:
# Push your local configuration to the staging service
graphcdn push --env staging
Note that you can only switch app
, schema
, and originUrl
per-environment. All the other configuration is shared between all the environments and can be pushed there accordingly. You can call your environments anything you want.
CI workflow
Assuming you have a "staging" branch (of some sort) in your VCS, we recommend automatically pushing to your "staging" environment from that CI and to the default (i.e. production) environment on your main
/ master
/ trunk
branch.
In pseudo-code, your CI configuration should do something like:
if ($BRANCH === "staging")
graphcdn push --env staging
else if ($BRANCH === "main")
graphcdn push