The instructions in this content include using GitHub Actions. Refer to GitHub’s documentation:GitHub Actions: Manually running a workflow for more details. |
This page provides an example of how to use the ghactions-run-workflow
CloudBees action to integrate a GitHub Actions (GHA) workflow into a CloudBees workflow. It includes details about prerequisites, example workflows, and advanced usage with parameters.
The ghactions-run-workflow
CloudBees action allows triggering a remote GitHub Actions workflow from within a CloudBees workflow. This integration enables seamless orchestration between CloudBees and GitHub Actions workflows.
All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Prerequisites
-
GitHub Actions workflow setup:
-
The GitHub Actions workflow must specify the
workflow_dispatch
trigger type to be invoked via REST API calls. -
Refer to GitHub documentation for details about manually running a workflow.
-
-
Github Token Permissions:
-
The GitHub token used by the
ghactions-run-workflow
action must have Actions:read/write permissions for the GitHub repository that owns the workflow.
-
Example GitHub Actions workflow
The following example demonstrates how to create a GitHub Actions workflow that can be triggered via the workflow_dispatch
API mechanism.
GitHub repository setup
Imagine a GitHub repository acme-org/hello-repo
containing the following file at .github/workflows/say-hello.yml
:
This workflow is triggered when a workflow_dispatch
event is sent to the repository. When triggered, the workflow runs the say-hello
job on a GitHub-hosted virtual machine, as specified by the runs-on syntax. GitHub provides these ephemeral VMs to execute workflows, provisioning a fresh instance for each job run.
Inputs and parameters for ghactions-run-workflow
The ghactions-run-workflow
action supports the following inputs:
Input name | Data type | Required? | Description | ||
---|---|---|---|---|---|
|
String |
No |
The GitHub server URL.
If not specified, uses |
||
|
String |
Yes |
The GitHub token. |
||
|
String |
Yes |
The GitHub organization name. |
||
|
String |
Yes |
The GHA repository name. |
||
|
String |
Yes |
The GHA branch name. |
||
|
String |
Yes |
The GHA workflow name.
|
||
|
String |
No |
Specifies the test type for generating a job test report. Supported test types are JUnit ( |
||
|
String |
No |
Specifies the test report file location.
Accepts pattern matching, such as |
||
|
JSON |
No |
Any additional parameters, formatted as JSON data in key/value pairs. |
Triggering the GitHub Actions workflow from CloudBees
Once the GitHub Actions workflow is defined, it can be triggered from a CloudBees workflow using the ghactions-run-workflow
action.
Example CloudBees workflow
Below is an example of a CloudBees workflow that triggers the GitHub Actions workflow defined above:
In this workflow:
1 | The CloudBees workflow is triggered on any push event. |
2 | The ghactions-run-workflow action sends a workflow_dispatch event to the GitHub Actions workflow using the specified parameters. |
3 | Logs and execution results from the GitHub Actions workflow are included in the output of the CloudBees step. |
Known issues
-
Parameters with spaces in their values can cause errors.
-
Improvements are planned to enhance logging and error messages.
Usage example
Below is another usage example for running a GitHub Actions workflow with additional test-related inputs: