GitHub Workflow Dispatcher
GitHub Workflow Dispatcher allows you to trigger Github workflows to deploy
software or infrastructure.
Enable GitHub Integration
Enable the GitHub integration in your
Ctrlplane workspace settings and invite the Github bot to your organization.
Workspace Settings > Integrations > GitHub
Creating a GitHub Workflow
Create a new workflow in your repository.
name: Receiving Workflow
run-name:
Receiving Workflow [${{ inputs.job_id }}]
on:
workflow_dispatch:
inputs:
job_id:
description: "Distinct ID"
required: false
Due to limitations of the GitHub API, workflows do not return the run ID. In order for Ctrlplane to get the ID, it generates a random one that is passed into the pipeline and is expected to be added to the Run name. This can be done by adding:
Retrieving Job Inputs
Next, configure the action to retrieve job inputs from Ctrlplane using the
get-job-inputs
action. You will need to provide the base URL of your Ctrl
Plane instance, the job_id
(input), and an API key stored in your GitHub
secrets.
jobs:
deploy-app:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: ctrlplane
uses: ctrlplanedev/ctrlplane/github/get-job-inputs@main
with:
base_url: https://ctrlplane.dev
job_id: ${{ inputs.job_id }}
api_key: ${{ secrets.CTRLPLANE_API_KEY }}
required_outputs: |
release_version
resource_config_name
# ... deploy your app to the resource
Commit Release Provider
Its commone to create a release for every commit to a repository. Here is an
example github aciton that creates a release for a given commit.
name: Create Release
on:
push:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Ctrlplane CLI
uses: ctrlplanedev/cli@main
with:
api_key: ${{ secrets.CTRLPLANE_API_KEY }}
version: v0.1.8
- name: Create Release
run: |
ctrlc api upsert release \
--version ${{ github.sha }} \
--name ${{ github.sha }} \
--deployment 00000000-0000-0000-0000-000000000000 \
--metadata branch=${{ github.ref }} \
--metadata commit=${{ github.sha }} \
--metadata message=${{ github.event.head_commit.message }} \
--metadata author=${{ github.event.head_commit.author.name }} \
--metadata email=${{ github.event.head_commit.author.email }} \
--metadata timestamp=${{ github.event.head_commit.timestamp }}