Deploy to Scalingo from CircleCI
This page describes the steps to setup Continuous Deployment from CircleCI to Scalingo. Follow this guide to automatically deploy to Scalingo after a successful build.
Setup .circleci/config.yml
To trigger a deployment after a successful build on CircleCI you have to add a deploy
job and configure workflows in your .circleci/config.yml
:
version: 2
jobs:
build:
steps:
# Add steps to build your app
deploy:
resource_class: small # Or another size, depending on your plan possibilities
docker:
- image: cimg/base:2023.10 # CircleCI base images include git by default
steps:
- checkout # Checkout your app's git repo
- run:
name: Add Scalingo to known_hosts
command: mkdir -p ~/.ssh && ssh-keyscan -H ssh.[region].scalingo.com >> ~/.ssh/known_hosts
- run:
name: Deploy on Scalingo
command: |
git push git@ssh.[region].scalingo.com:my-app.git master
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
You can read more about Configuring CircleCI Deployment on the CircleCI documentation.
SSH Keys
To deploy to Scalingo from CircleCI, you’ll have to add your private key to the CircleCI interface. On CircleCI website, head over to your project’s Project Settings, then the SSH keys page to add your key. You will also need to add the public key to the SSH Keys page on Scalingo Dashboard.
We recommend to generate a new key pair for integrating CircleCI with Scalingo.
Executing post-deployment commands
You can define postdeploy hook integrated in your Procfile. If you
still prefer to run post-deployment commands at CircleCI level, you will have to
download our command line tool in the CircleCI environment and use the scalingo
run
command.
command: |
ssh-keyscan -H ssh.[region].scalingo.com >> ~/.ssh/known_hosts
git push git@ssh.[region].scalingo.com:my-app.git $CIRCLE_SHA1:master
curl -LO https://github.com/Scalingo/cli/releases/download/1.6.0/scalingo_1.6.0_linux_amd64.tar.gz
tar xvf scalingo_1.6.0_linux_amd64.tar.gz
scalingo_1.6.0_linux_amd64/scalingo --app my-app login --ssh
scalingo_1.6.0_linux_amd64/scalingo --app my-app run rake db:migrate