download-buildkite-artifact-action

GitHub Action to download artifacts from Buildkite.

APACHE-2.0 License

Stars
2
Committers
1

GitHub Action to download Buildkite Artifacts

This GitHub Action downloads artifacts from a Buildkite pipeline that builds the respective commit.

The action picks up a Buildkite build from the commit status that is set by Buildkite integration with Github, which looks like this:

After termination of the Buildkite build, the action downloads finished artifacts into your GitHub workflow where you can use them in other steps and jobs.

You can add this action to your GitHub workflow for Ubuntu Linux (e.g. runs-on: ubuntu-latest) runners:

- name: Buildkite Artifacts
  uses: EnricoMi/download-buildkite-artifact-action@v1
  with:
    buildkite_token: ${{ secrets.BUILDKITE_TOKEN }}
    output_path: artifacts

Use this for macOS (e.g. runs-on: macos-latest) and Windows (e.g. runs-on: windows-latest) runners:

- name: Buildkite Artifacts
  uses: EnricoMi/download-buildkite-artifact-action/composite@v1
  with:
    buildkite_token: ${{ secrets.BUILDKITE_TOKEN }}
    output_path: artifacts

Trigger a build and download its artifacts

You can trigger a Buildkite build with the buildkite/trigger-pipeline-action action and then download the artifacts from that build:

steps:
- name: Trigger Buildkite Pipeline
  id: build
  uses: buildkite/[email protected]
  env:
    PIPELINE: "<org-slug>/<pipeline-slug>"
    BUILDKITE_API_ACCESS_TOKEN: ${{ secrets.BUILDKITE_TOKEN }}

- name: Download Buildkite Artifacts
  uses: EnricoMi/download-buildkite-artifact-action@v1
  with:
    buildkite_token: ${{ secrets.BUILDKITE_TOKEN }}
    buildkite_build_url: ${{ steps.build.outputs.url }}
    ignore_build_states: blocked,canceled,skipped,not_run
    ignore_job_states: timed_out,failed
    output_path: artifacts

Permissions

It is generally good practice to restrict permissions for actions in your workflows and jobs to the required minimum.

When buildkite_build_url is provided, no permissions are needed by this action at all:

permissions: {}

When buildkite_build_url is not provided, the action picks up any Buildkite check created by Buildkite integration with Github. Then, the following permissions are required:

permissions:
  metadata: read
  contents: read
  statuses: read

Configuration

The output_path and log_level variables are optional. Their default values are . (current directory) and INFO, respectively. The Python logging module defines the available log levels.

You have to provide a Buildkite API Access Token via buildkite_token to be stored in your GitHub secrets. This Buildkite token requires read_artifacts and read_builds scopes:

Artifacts are stored under the following path: {output_path}/{job_name}/{artifact_path}

  • The output_path is a configured above or defaults to the current directory.
  • The job_name avoids conflicts between artifacts that have the same artifact_path in different jobs.
  • The artifact_path is the path and filename for the artifact as displayed on the Buildkite build page:

Outputs

The action provides the following outputs:

output description
build-number The number of the Buildkite build
build-state The state of the Buildkite build: passed, failed, blocked, canceled, skipped, not_run
download-state The outcome of downloading artifacts: skipped, success, failure
download-paths The paths of the downloaded artifacts as a Json array of strings
download-files The number of downloaded files
Package Rankings
Top 16.91% on Github actions
Related Projects