IntegrationsGitHubActions Dispatcher

Actions Dispatcher

GitHub Actions Dispatcher allows you to trigger other GitHub Actions workflows from a single workflow. This is useful when you want to run multiple workflows in parallel or trigger a workflow from another repository.

Creating Actions

Due to limitations of the GitHub API, workflows do not return the run ID. In order for Ctrl Plane 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:

name: Receiving Workflow
run-name:
  Receiving Workflow [${{ inputs.distinct_id && inputs.distinct_id || 'N/A' }}]
 
on:
  workflow_dispatch:
    inputs:
      distinct_id:
        description: "Distinct ID"
        required: false

Configuring Workflows with Ctrl Plane

To integrate Ctrl Plane’s get-job-inputs action into a workflow, follow the steps below. This action allows you to pass job inputs like release_version and resource_config_deployment_id to your workflows.

First, ensure the workflow can be triggered by a dispatch event:

on:
  workflow_dispatch:
    inputs:
      job_id:
        description: "Job execution ID"
        required: true

Next, configure the action to retrieve job inputs from Ctrl Plane 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.

Example configuration:

jobs:
  set-deployment-spec:
    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_deployment_id

This example shows how the workflow retrieves specific values, such as release_version and resource_config_deployment_id, to be used in subsequent steps. The action integrates seamlessly with Ctrl Plane to ensure the proper data is fetched and utilized within your pipeline.

Key Steps to Integrate:

  1. Use workflow_dispatch to allow manual triggering.
  2. Pass the necessary job_id input when dispatching.
  3. Ensure the get-job-inputs action is correctly configured with the base_url, job_id, and CTRLPLANE_API_KEY as shown above.
  4. Specify the required outputs that will be used in your workflow.
Ctrlplane
© 2024 Ctrlplane. All rights reserved.