To start create a new Bolt schedule and make sure to add the deferred_schedule configuration. Depending on your intended behavior you can choose to defer to another production job or defer back to the last CD run.
The deferred_schedule_name set in the configuration should have at least one successful run available so that Paradime can pick the manifest.json for state comparison.
Example schedule
... - name:continuous_deployment_run# the name of your CD jobdeferred_schedule:enabled:true# true to enabled this Turbo CI job to run on pull request deferred_schedule_name: hourly_run #the name of the bolt schedule where the CD job will look for the most recent successful run manifest.json for state comparison
schedule:"OFF"# set the schedule configuration to not run on a schedule (to be used for PR only)environment:production#the environment used to run the schedule -> this is always productioncommands: - dbt run --select state:modified+#the dbt™️ command you want to run after the pull request is mergedowner_email:"john@acme.io"#the email of the CD job owner_email...
Generate API keys and find you workspace token
API keys are generated at a workspace level.
To be able to trigger Bolt using the API, you will first need to generate API keys for your workspace. Got to account settings and generate your API keys, make sure to save in your password manager:
API key
API secret
API Endpoint
Workspace token
You will need this later when setting up the secret in GitHub
Create a folder called .github and let's add a subfolder called workflows in your dbt™️ repository. Here we can add a new paradime_cd.yml file. Copy the code block below and enter the values required.
Example GitHub action configuration file
paradime_cd.yml
name:paradime_continuous_deploymentenv:SCHEDULE_NAME:<the schedule name set in Paradime>#example continuous_deployment_run API_ENDPOINT: <the api endpoint generated in the previous step> #example https://api.paradime.io/api/v1/uany7ed234ovarzx/graphql
API_SECRET:${{ secrets.PARADIME_API_SECRET }}API_KEY:${{ secrets.PARADIME_API_KEY }}WORKSPACE_TOKEN:<the workspace token generated in the previous step>#example 8p232d9mo4cvea9w BASE_PARADIME_BOLT_URL: <the Paradime URL of your instance, make sure to include /bolt/run_id/> # Example https://app.paradime.io/bolt/run_id/
on:push:pull_request:branches: - maintypes: [closed]jobs:trigger_paradime_bolt:if:${{ github.event.pull_request.merged }}runs-on:ubuntu-latesttimeout-minutes:60steps: - name:Set up Pythonuses:actions/setup-python@v2with:python-version:'3.8'# Specify the version of Python you want to use - name:Install dependenciesrun:| python -m pip install --upgrade pip pip install paradime-io - name:Trigger Bolt Run and Check Statusshell:pythonenv:PYTHONUNBUFFERED:1run:| import time from paradime import Paradime # Create a Paradime client with your API credentials paradime = Paradime(api_endpoint='${{ env.API_ENDPOINT }}', api_key='${{ env.API_KEY }}', api_secret='${{ env.API_SECRET }}') # Trigger a run of the Bolt schedule and get the run ID run_id = paradime.bolt.trigger_run(schedule_name='${{ env.SCHEDULE_NAME }}', branch='${{ github.event.pull_request.base.ref }}') if not run_id: raise Exception("Failed to trigger Bolt run") print( f'Triggered Bolt Run. View run details: "${{ env.BASE_PARADIME_BOLT_URL }}{run_id}?workspaceToken=${{ env.WORKSPACE_TOKEN }}"'
) # Continuously check the run status while True: run_status = paradime.bolt.get_run_status(run_id) print(f'Run Status: {run_status}') if run_status != 'RUNNING': break # Exit loop if status is anything other than RUNNING time.sleep(10) # Wait for 10 seconds before checking again exit(0 if run_status == 'SUCCESS' else 1)
Add the API keys and Credentials in the GitHub actions secrets
Finally, you need to add the API key and credentials generated in the previous step in GitHub.
Set the corresponding values using your credentials for the variable names: