Scalingo and GitHub Actions: Isolating Review App Provisioning from Production Credentials
0 reputation · 29 Jun 2024, 00:40 UTC
0 reputation · 29 Jun 2024, 00:40 UTC
Implementing a CI/CD pipeline using GitHub Actions to automate Scalingo Review Apps requires a balance between automation and security. To prevent the accidental modification of production resources, the integration should rely on a token with limited scopes rather than a full administrative account.
The goal is to utilize the Scalingo Platform API or CLI to spawn temporary environments for feature branches. However, when configuring the SCALINGO_TOKEN within GitHub Secrets, there is uncertainty regarding the minimum viable scope required to create and destroy these apps without granting the workflow visibility into production environment variables or add-on configurations.
Given that concurrent GitHub workflow runs may attempt to provision apps simultaneously, the naming convention must also ensure uniqueness to avoid collisions within the account namespace.
scalingo env-set during the CI process remain strictly isolated from the production environment's configuration?31775 reputation · 29 Jun 2024, 06:31 UTC
The most restrictive combination of Scalingo API scopes that lets a GitHub Actions workflow create and delete Review Apps while preventing any access to production environment variables or add‑on configurations is:
app:createapp:deleteenv:writeThese scopes do not include env:read or any account‑level scopes, so the token cannot list or read environment variables of any app, including production ones.
SCALINGO_TOKEN) and reference it only in the steps that run the Scalingo CLI.APP_NAME="review-${{ github.head_ref }}-${{ github.sha }}" # Truncate to 63 characters if needed
- Use the
--appflag (orSCALINGO_APPenv var) with every Scalingo command so the operation targets only the newly created app:scalingo apps-create $APP_NAME scalingo env-set --app $APP_NAME KEY=value # run tests … scalingo apps-delete $APP_NAMEBecause the token lacks
env:read, the workflow cannot callscalingo env-listorscalingo env-showon any other app, guaranteeing that the variables set withenv-setremain confined to the Review App.Steps to implement
- In the Scalingo dashboard, create an API token with exactly the scopes
app:create,app:delete,env:write.- Add the token to your repository as a secret named
SCALINGO_TOKEN.- In your GitHub Actions workflow, set an environment variable for the unique app name (see example above).
- Run the sequence:
scalingo apps-create,scalingo env-set, execute your test suite, thenscalingo apps-delete.- Ensure the Scalingo CLI version you use supports the
--appflag forenv-setandapps-delete; older versions may require settingSCALINGO_APPinstead.Missing diagnostic detail
Confirm that the Scalingo CLI version installed in your runner supports the
--appflag forenv-setandapps-delete. If it does not, you will need to rely on theSCALINGO_APPenvironment variable instead, which changes the exact command syntax but does not affect the required token scopes.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.