Triggering pipelines using GitHub Actions

GitHub Actions is a GitHub-based workflow automation platform. You can use the GitHub actions Trigger Buildkite Pipeline to trigger a build on a Buildkite pipeline.

The Trigger Buildkite Pipeline GitHub Action allows you to:

  • Create builds in Buildkite pipelines and set commit, branch, message.
  • Save the build JSON response to ${HOME}/${GITHUB_ACTION}.json for downstream actions.

Find the Trigger Buildkite Pipeline on GitHub Marketplace or follow this link directly.

Trigger Buildkite Pipeline GitHub Action on GitHub

Before you start

This tutorial assumes some familiarity with GitHub and using GitHub Actions. Learn more about GitHub Actions from their documentation.

Creating the workflow for Buildkite GitHub Actions

  1. If a workflow directory does not exist yet, create the .github/workflows directory in your repo to store the workflow files for Buildkite Pipeline Action.
  2. Create a Buildkite API access token with write_builds scope, and save it to your GitHub repository’s Settings in Secrets. You can read more about Creating encrypted secrets for a repository in GitHub.
  3. Define your GitHub Actions workflow with the details of the pipeline to be triggered. To ensure that the latest version is always used, click "Use latest version" on the Trigger Buildkite Pipeline page. Copy and paste the code snippet provided.
  4. Configure the workflow by setting the applicable configuration options.

Example workflow

The following workflow creates a new Buildkite build on every commit (change my-org/my-deploy-pipeline to the slug of your org and pipeline, and TRIGGER_BK_BUILD_TOKEN to the secrets env var you have defined):

trigger-pipeline-action.yml
on: [push]

steps:
   - name: Trigger a Buildkite Build on Push using v2.0.0
        uses: buildkite/trigger-pipeline-action@v2.0.0
        with:
          buildkite_api_access_token:  ${{ secrets.TRIGGER_BK_BUILD_TOKEN }} 
          pipeline: "lzrinc/experimental-pipeline"      
          branch: master
          commit: HEAD
          message:  "<img class="emoji" title="buildkite" alt=":buildkite:" src="https://buildkiteassets.com/emojis/img-buildkite-64/buildkite.png" draggable="false" /><img class="emoji" title="github" alt=":github:" src="https://buildkiteassets.com/emojis/img-buildkite-64/github.png" draggable="false" /> 🚀🚀🚀 Triggered from a GitHub Action"     

Configuring the workflow

Refer to the action.yml for the input parameters required.

See Trigger-pipeline-action for more details, code, or to contribute to or raise an issue for the Buildkite GitHub Action.