CI/CD Pipeline Integration

Integrate servicefoundry in a CI/CD pipeline

Introduction

Deployments using servicefoundry can be seamlessly integrated with any CI/CD pipeline solutions like Github Actions, Jenkins etc. The following steps show you how to setup Github Actions to automatically deploy your application to TrueFoundry.

Before you start

Make sure the following steps have been completed before moving ahead:

Steps

  • Get your API key from the dashboard.
  • Add the API key to the Github repository as a secret with key SERVICE_FOUNDRY_API_KEY.

Adding the secret

  • In your repository, create a folder for Github Actions
    mkdir -p .github/workflows
    
  • Create a file called sfy-deploy.yaml in this folder and paste the below content:
    # Replace `<your-workspace-fqn>` with the FQN of the workspace where
    # you want to deploy your code.
    name: sfy deploy
    on:
      push:
        branches:
        - main
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
        - run: echo "Deploying ${{ github.ref }} to servicefoundry"
        - name: Install sfy
          run: pip install servicefoundry
        - name: Check out repository code
          uses: actions/[email protected]
        - name: Deploy
          run: sfy deploy --workspace-fqn <your-workspace-fqn>
          env:
            SERVICE_FOUNDRY_API_KEY: ${{ secrets.SERVICE_FOUNDRY_API_KEY }}
    
  • Commit this file to main. This will trigger the pipeline and deploy the code on main to TrueFoundry

You can find code for a digit recognition service that is deployed to TrueFoundry using Github Actions here.