Skip to main content

CI/CD

Introduction​

This guide explains how to migrate your CI/CD pipeline from Heroku to Massdriver, including continuous integration (CI) and continuous deployment (CD) to Azure services.

For a video guide on setting up GitHub Actions for Massdriver, watch the video below:

Prerequisites​

  • Your application code must be hosted in version control in a public or private repository, e.g. GitHub or Azure Repos.
  • Massdriver account

Step 1: Continuous Integration (CI)​

  1. Copy the following link and replace <org/username> and <repo-name> with your GitHub organization or username and repository name:

    https://github.com/<org/username>/<repo-name>/actions/new?category=continuous-integration
  2. Open the link in your browser. You will be presented with available workflows for continuous integration based on your application's runtime environment.

  3. Click Configure on the workflow that best suits your application's requirements (Node.js, Python, Go, etc.).

  4. Customize the workflow file as needed and then click Commit changes to add it to your repository's .github/workflows directory.


Step 2: Continuous Deployment (CD)​

To deploy your application in Massdriver, we need a workflow that builds and pushes your Docker image to Azure Container Registry, publishes changes to your application bundle, updates the image tag in your application manifest, and redeploys the application in the Massdriver platform.

  1. Create a new workflow file in your repository's .github/workflows directory. For example, .github/workflows/massdriver-deploy.yml:

    name: Deploy to Massdriver
    on:
    push:
    branches: [main]

    jobs:
    push_and_deploy:
    runs-on: ubuntu-latest
    env:
    MASSDRIVER_ORG_ID: ${{ secrets.MASSDRIVER_ORG_ID }}
    MASSDRIVER_API_KEY: ${{ secrets.MASSDRIVER_API_KEY }}
    steps:
    - uses: actions/checkout@v4
    - name: Install Massdriver CLI
    uses: massdriver-cloud/actions@v4
    - name: Push Image
    uses: massdriver-cloud/actions/image_push@v4
    with:
    namespace: ${{ vars.NAMESPACE }}
    image-name: ${{ vars.IMAGE_NAME }}
    artifact: ${{ secrets.MASSDRIVER_ARTIFACT_ID }}
    region: ${{ vars.REGION }}
    image-tag: ${{ github.sha }}
    build-context: ./ # path to Dockerfile
    - name: Publish Bundle
    uses: massdriver-cloud/actions/bundle_publish@v4
    with:
    build-directory: ./massdriver # path to massdriver config directory, contains massdriver.yaml
    - name: Set Image Version
    uses: massdriver-cloud/actions/app_patch@v4
    with:
    project: <insert-project-abbreviation-here>
    env: <insert-environment-abbreviation-here>
    manifest: <insert-manifest-abbreviation-here>
    set: |
    .image.tag = "${{ github.sha }}"
    - name: Deploy App
    uses: massdriver-cloud/actions/app_deploy@v4
    with:
    project: <insert-project-abbreviation-here>
    env: <insert-environment-abbreviation-here>
    manifest: <insert-manifest-abbreviation-here>
  2. Replace the placeholders in the workflow file as needed, then save and commit the changes to your repository.