Continuous Integration & Delivery (CI/CD)
This page is an agnostic overview of how to use our platform to build and deploy your project with a platform like GitHub Actions or GitLab CI. This will give you keys to create the perfect script to deploy your project. There is an example for GitHub Actions and GitLab CI at the end of this page.
Environment variables
First of all, you need to define the environment variables you need to deploy successfully your project. You need at least two values to use them with the CLI:
- your project's name
- your project's environment
env:
ORG_PROJECT: my-project
DEPLOY_ENV: test
Login
To deploy, you need to be connected to your ScaleDynamics account. The easiest way to do it with a CI is to use an API key. You can create one in the API key section of your organization in the ScaleDynamics console (opens in a new tab).
The API key require Administrator rights.
- name: Connection to ScaleDynamics
run: npx warp login --api-key=${{ secrets.SCALEDYNAMICS_API_KEY }}
Deploy
To deploy your project, you need to use the environment variables defined earlier and use it with the CLI.
- name: Deploy application
run: npx warp deploy --project ${ORG_PROJECT} --env ${DEPLOY_ENV}
Example on GitHub and GitLab
name: deploy
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy:
runs-on: ubuntu-latest
env:
ORG_PROJECT: my-project
DEPLOY_ENV: test
steps:
- uses: actions/checkout@v2
- name: Install dependencies application
run: npm ci
# Create an API key in the console and use it for connection (you can add it as a secret)
- name: Connection to ScaleDynamics
run: npx warp login --api-key=${{ secrets.SCALEDYNAMICS_API_KEY }}
- name: Build project
run: npm run build
- name: Deploy application
run: npx warp deploy --project ${ORG_PROJECT} --env ${DEPLOY_ENV} --force
Advanced pipelines
You can pretty much add anything else you need to do with your project. Add unit tests, build your project if needed, lint your code, etc. Use our SDK command lines for interactions with our platform. By default, all SDK CLIs are interactive. In order to use them in CI/CD pipelines, you have a way to indicate all required parameters to avoid interactivity to build your pipeline.
Here is a snippet of code to create a project, an environment, set the runner and the url to deploy a container and deploys it.
The snippet suppose you have environment variables set:
PROJECT
: the name of the project you want to deployENV
: the name of the environment you want to deploy (dev, prod, live, …)APIKEY
: A ScaleDynamics API key with 'Administrator' rights.SERVICE_NAME
: the name of the container service to deploy (https://docs.scaledynamics.com/docs/services/deployment#setting-service-name (opens in a new tab)), for exemple 'app'
:::info
To create an API key, goes in the console on the organization level, and opens 'API key' tab. Then add an API key.
When done, use the token as the APIKEY
.
:::
# Create project
warp --api-key "$APIKEY" project create "$PROJECT"
# Create env
warp --api-key "$APIKEY" env create "$ENV" --project "$PROJECT"
# Configure env
## Configure URL on a random managed url (use "" to indicate a random url)
warp --api-key "$APIKEY" env base-url add "$SERVICE_NAME" "" --project "$PROJECT" --env "$ENV"
## Configure runner
warp --api-key "$APIKEY" env runner set "$SERVICE_NAME" "$RUNNER_NAME" --project "$PROJECT" --env "$ENV"
# Deploy a Dockerfile from a 'my-container' directory
warp --api-key "$APIKEY" deploy --project "$PROJECT" --env "$ENV" my-container
You can also use CLIs to remove envs or projects.
# Remove env
warp --api-key "$APIKEY" env delete "$ENV" --project "$PROJECT" --yes
# Remove the project
warp --api-key "$APIKEY" project delete "$PROJECT" --yes