跳到主要内容

Trigger

Horizon provides a trigger mechanism to trigger a pipeline when a specified event occurs. Now we support Github Action and Gitlab CI/CD.

Github Action

We provide an action, and you could just use it in your workflow file.

Below is an example of a workflow file:

name: Deploy to Horizon

on:
push:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: horizoncd/actions@v1
with:
token: {{ secrets.HORIZON_TOKEN }}
addr: {{ secrets.HORIZON_ADDR }}
deployMethod: buildDeploy
title: 'deployment from github'
instanceID: 61851
gitRefType: commit
ref: ${{ github.sha }}

This action will trigger a pipeline to deploy your commit when a push event occurs on the main branch.

Gitlab CI/CD

We provide a cli tool horizoncd, and you could just use it in your gitlab-ci.yml file, but it requires nodejs environment.

Below is an example of a gitlab-ci.yml file:

stages:
- deploy

build:
stage: deploy
script:
- npm install horizoncd npx
- npx horizoncd \
-a $HORIZON_ADDR \
-t $HORIZON_TOKEN \
-c 61862 \
--title 'deploy from gitlab' \
-m builddeploy \
-r $CI_COMMIT_SHA

variables:
HORIZON_ADDR: $HORIZON_ADDR
HORIZON_TOKEN: $HORIZON_TOKEN

Varaibles

NameDescriptionRequired
tokenHorizon token with instance-write permissions for horizontrue
addrAddress of Horizon instancetrue
titlePipeline titletrue
descriptionPipeline descriptionfalse
instanceIDApplication instance IDtrue
deployMethodbuildDeploy or imageDeploy, method to deploy the apptrue
gitRefTypebranch, tag or commit only, required if deployMethod is "buildDeploy"false
refGit ref, tag, branch or commit idfalse
tagtag of the image which are going to be deployed, required if deployMethod is "imageDeploy"false