Github action step
GitHub Actions let you create custom actions that can perform predefined tasks. These predefined tasks range from cloning a codebase to building a Docker image and security scanning images. Previously-created actions are present on the GitHub marketplace, with a rich support of over 10k actions.
Harness CI has added a native Action
step type for running GitHub Actions.
The Action step is supported in Harness Cloud build infrastructures only.
Examples
- Setup Golang
- Setup Java
- Setup Ruby
This step sets up a go environment for the following steps in the stage to use.
- step:
type: Action
name: setup golang
identifier: setup_go
spec:
uses: actions/setup-[email protected]
with:
go-version: '1.17'
This step sets up a java environment for the following steps in the stage to use.
- step:
type: Action
name: setup java
identifier: setup_java
spec:
uses: actions/setup-[email protected]
with:
java-version: '17'
This step sets up a Ruby environment for the following steps in the stage to use.
- step:
type: Action
name: setup ruby
identifier: setup_ruby
spec:
uses: shubham149/setup-[email protected]
with:
ruby-version: '2.7.2'
spec
parameter reference
uses
: The GitHub repository of the action along with the branch or tag.with
: A map with a key and value as string. These are action inputs.env
: Environment variables passed to the action.
Action step yaml in Github action vs Harness CI
To create action step in harnessCI, copy the uses
, with
and env
attributes from the GitHub action YAML and paste it in spec section of harness action step yaml
Github action yaml | Harness CI Action step yaml |
|
|
Example pipeline
This pipeline installs golang version 1.19.5 using an Action step, compiles the golang application, and runs the tests.
pipeline:
name: Build and test golang application
identifier: Build_test_golang
projectIdentifier: defaul
orgIdentifier: default
tags: {}
properties:
ci:
codebase:
connectorRef: Github_connector
build: <+input>
stages:
- stage:
name: Build golang application
identifier: Build_golang_application
description: ""
type: CI
spec:
cloneCodebase: true
platform:
os: Linux
arch: Amd64
runtime:
type: Cloud
spec: {}
execution:
steps:
- step:
type: Action
name: setup golang
identifier: setup_go
spec:
uses: actions/setup-[email protected]
with:
go-version: 1.19.5
- step:
type: Run
name: Build and test
identifier: Build_and_test
spec:
shell: Bash
command: |-
go build .
go test -v ./...