Skip to content

Commit f0a62f8

Browse files
First version of Readme
1 parent 1f978a2 commit f0a62f8

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
1-
# codefresh-github-action-test
2-
we want to see what valuable codefresh capabilities can be exposed through Github actions
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+
* An environment variable called `BRANCH` with the git branch that you want to use for the trigger.
40+
41+
Click the Done button to save your changes.
42+
43+
Now next time you commit anything in your Github repository the Codefresh pipeline will also execute.
44+
45+
46+
47+
48+

0 commit comments

Comments
 (0)