Skip to content

Commit 398d251

Browse files
refactor
1 parent abb044a commit 398d251

File tree

3 files changed

+47
-11
lines changed

3 files changed

+47
-11
lines changed

.github/main.workflow

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
workflow "test-runner" {
1+
workflow "pipeline-runner" {
22
on = "push"
3-
resolves = ["test-pipeline-runner"]
3+
resolves = ["run-pipeline"]
44
}
55

6-
action "test-pipeline-runner" {
6+
action "run-pipeline" {
77
uses = "./"
88
secrets = ["CF_API_KEY"]
9-
env = {
10-
PIPELINE_NAME = "runp/runp"
11-
TRIGGER_NAME = "codefresh-io/codefresh-github-action-test"
12-
}
139
}

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM codefresh/cli
22

3-
LABEL "com.github.actions.name"="test-pipeline-runner"
4-
LABEL "com.github.actions.description"="allow run custom codefresh pipeline"
3+
LABEL "com.github.actions.name"="codefresh-pipeline-runner"
4+
LABEL "com.github.actions.description"="allows to run custom codefresh pipelines"
55
LABEL "com.github.actions.icon"="mic"
66
LABEL "com.github.actions.color"="purple"
77

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,42 @@
1-
# codefresh-github-action-test
2-
This action allow run custom codefresh pipeline
1+
# Integrating Codefresh pipelines with Github actions
2+
3+
Github actions are a flexible way to respond to Github events and perform one or more tasks
4+
when a specific Github event happens. Github actions can also use Codefresh pipeline as a back-end
5+
resulting in a very powerful combination where the first action starts from Github, but Codefresh takes care
6+
of the actual compilation or deployment in a pipeline.
7+
8+
9+
## Codefresh Github action
10+
11+
This repository holds a Github action that can be used to call existing [Codefresh pipelines](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/pipelines/). It is based on the [Codefresh CLI](https://codefresh-io.github.io/cli/) which can execute Codefresh pipelines remotely (using an API key for authentication). The Codefresh CLI is already available as a [public Docker image](https://hub.docker.com/r/codefresh/cli/), so creating a Github action with it is a trivial process.
12+
13+
## Prerequisites
14+
15+
Make sure that you have
16+
17+
* a Github account with Actions enabled
18+
* a [Codefresh account](https://codefresh.io/docs/docs/getting-started/create-a-codefresh-account/) with one or more existing pipelines ready
19+
* a [Codefresh API token](https://codefresh.io/docs/docs/integrations/codefresh-api/#authentication-instructions) that will be used as a secret in the Github action
20+
21+
22+
## How the Codefresh action works
23+
24+
The Github workflow is placed on the [push event](https://developer.github.com/v3/activity/events/types/#pushevent) and therefore starts whenever a Git commit happens. The Workflow has a single action that starts the Codefresh pipeline runner.
25+
26+
The pipeline runner is a Docker image with the Codefresh CLI. It uses the Codefresh API token to authenticate to Codefresh and then calls a an existing pipeline via its trigger.
27+
28+
The result is that all the details from the Git push (i.e. the GIT hash) are transferred to the Codefresh pipeline that gets triggered remotely
29+
30+
## How to use the Codefresh Github action
31+
32+
In order to use the Github action, fork this repository and then navigate to the "Actions" tab in Github. Click on the "View main.workflow" button on the right hand side. Make sure that an actual branch is selected on the top left of the window. Then click the "Edit this file" button in the main workarea (exactly as you would edit a normal git file via Github)
33+
34+
Select the pipeline runner action and click the "Edit" button. On the right side panel enter the following
35+
36+
* A secret with name `CF_API_KEY` and value your Codefresh API token
37+
* An environment variable called `PIPELINE_NAME` with a value of `<project_name>/<pipeline_name>`
38+
* An environment variable called `TRIGGER_NAME` with trigger name attached to this pipeline. See the [triggers section](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/triggers/) for more information
39+
40+
Click the Done button to save your changes and commit.
41+
42+
Now next time you commit anything in your Github repository the Codefresh pipeline will also execute.

0 commit comments

Comments
 (0)