Github Actions is a GitHub feature that enables you to automate various event-driven activities in GitHub, such as cloning a repository, generating Docker images, and testing scripts.
Harness CI supports launching GitHub Actions as part of a Pipeline Stage using the Plugin step.
You simply use the GitHub Actions Drone Plugin, plugins/github-actions, in the Plugin step, and then replicate the GitHub Action settings.
The Github Actions Drone Plugin runs your GitHub Actions in the background using nektos/act.
In this topic, we cover using GitHub Actions in the Plugin step with one of the several GitHub Actions listed in GitHub Marketplace.
Before You Begin
Step 1: Create the CI Stage
In your Harness Pipeline, click Add Stage, and then click CI.
Step 2: Add the Codebase
In Connector, select an existing Connector to your codebase repo, or create a new one. See Code Repo Connectors.
You can see the URL for the repo account below Repository Name. Don't add the URL into Repository Name.
In Repository Name, enter the name of the repo containing the codebase.
For example, if the account URL is
https://github.com/mycompany and the repo in that account is
myapp in the Repository Name.
Step 3: Define the Build Farm Infrastructure
In the CI stage Infrastructure, define the build farm for the codebase.
The following example uses a Kubernetes cluster build farm. You can use AWS for your build infrastructure as well. See Set Up an AWS VM Build Infrastructure.
In Select a Kubernetes Cluster, select, or create, a Kubernetes Connector. See Kubernetes Cluster Connector Settings Reference. This Connector connects Harness to the cluster to use as the build farm.
In Namespace, enter the Kubernetes namespace to use. You can use a Runtime Input (
<+input>) or expression also. See Runtime Inputs.
See Define a Kubernetes Cluster Build Infrastructure for more information.
Step 4: Add the Plugin step
In the stage's Execution, click Add step, select Plugin.
The Plugin settings appear.
Enter the following settings:
|Name||Enter a unique name for the step.|
|Description||Harness automatically generates a unique ID for the step.|
|Container Registry||Select or create a Harness Connector for the container registry.|
|Image||Enter the name of the Drone Plugin: |
|Privileged||The Drone Plugin uses nektos/act to run GitHub Actions in CI. It requires DIND (docker-in-docker) to run your images. Hence, the Privileged attribute needs to be enabled to run with escalated permissions.|
|Settings||Replicate the GitHub Action attributes under Settings. See the following example.|
Replicate the GitHub Action attributes under Settings. For example:
name: It refers to the GitHub repo of action along with branch or tag.
with: It is a map with key and value as strings. These are inputs to the GitHub Actions.
env: Environment variables passed to the GitHub Actions.
For example, for the Upload Cloud Storage Action, the attributes are as follows:
uses: google-github-actions/[email protected]
<+stage.variables.GCP_SECRET_KEY_BASE64> setting uses a Stage variable and a Harness Secret. See Add a Stage.
Here's an example:
For the step settings on CI Plugins, see Plugin Step Settings.
If you are trying to use an action composite that is located in a private repository, you will need to set a
GITHUB_TOKEN environment variable on the plugin step. Make sure the token has pull permissions to the target repository.
name: private action
uses: myorg/[email protected]
Step 5: View the Results
Save the Pipeline and click Run.
You can see the logs for the GitHub GCP Upload Action in the Pipeline as it runs.
Configure As Code: YAML
To configure your pipeline as YAML in CI, go to Harness Pipeline Studio and select YAML. The following is a working example of GitHub Action Cloud Storage Upload to GCP in CI. Modify the YAML attributes such as name, identifiers, codebase, connector ref, and environment variables based on your pipeline requirements.
name: gcp-upload-github-action # Configure your Pipeline name
identifier: gcpuploadgithubaction # Configure your Pipeline identifier
projectIdentifier: Demo_CI_pipelines # Configure your Project identifier
orgIdentifier: default # Configure your Organization
identifier: gcp_upload_success_gha # Configure your Stage identifier
name: stage 1
- name: GCP_SECRET_KEY_BASE64 # Configure your Secret Key Name
value: gcpbase64secret # Configure your Secret Key Value
identifier: gcsuploader # Configure your step identifier name
name: step one # Configure your step name
settings: # Configure your plugins Settings configuration
uses: google-github-actions/[email protected]
infrastructure: # Configure your Infrastructure Settings
codebase: # Configure your Codebase