diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14ad1fe..1f441b6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: run codefresh pipeline on: push jobs: build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@master diff --git a/README.md b/README.md index fdb7c65..03c55f6 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ when a specific GitHub event happens. GitHub actions can also use Codefresh pipe resulting in a very powerful combination where the first action starts from GitHub, but Codefresh takes care of the actual compilation or deployment in a pipeline. + + ## Prerequisites Make sure that you have @@ -43,17 +45,20 @@ jobs: uses: actions/checkout@master - name: 'run pipeline' - uses: actions/codefresh-pipeline-runner@v1 + uses: codefresh-io/codefresh-pipeline-runner@v8 + with: + args: '-v key1=value1 -v key2=value2' env: PIPELINE_NAME: 'codefresh-pipeline' TRIGGER_NAME: 'codefresh-trigger' - CF_API_KEY: ${{ secrets.GITHUB_TOKEN }} + CF_API_KEY: ${{ secrets.CF_API_KEY }} id: run-pipeline ``` ### Env variables * A secret with name `CF_API_KEY` and value your Codefresh API token ( https://codefresh.io/docs/docs/integrations/codefresh-api/#authentication-instructions ) * An environment variable called `PIPELINE_NAME` with a value of `/` * An optional 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 +* An optional environment variable called `CF_BRANCH` with branch name . Click the Done button to save your changes and commit. diff --git a/action.yml b/action.yml index f33dc6b..ba52678 100644 --- a/action.yml +++ b/action.yml @@ -1,9 +1,15 @@ name: 'Codefresh pipeline runner' description: 'Github action that runs codefresh pipeline' -author: 'codefresh' +author: 'codefresh-inc' +inputs: + args: + description: 'codefresh cli build variables, see https://codefresh-io.github.io/cli/pipelines/run-pipeline/#setting-variables-through-the-command for more information.' + required: false branding: icon: 'arrow-right-circle' color: 'green' runs: using: 'docker' image: 'Dockerfile' + args: + - ${{ inputs.args }} diff --git a/art/github-action-demo.gif b/art/github-action-demo.gif new file mode 100644 index 0000000..a98bdce Binary files /dev/null and b/art/github-action-demo.gif differ diff --git a/runner-entrypoint.sh b/runner-entrypoint.sh index d9eec9b..59aeaf7 100755 --- a/runner-entrypoint.sh +++ b/runner-entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # parse branch if [ -f $GITHUB_EVENT_PATH ]; then @@ -8,18 +8,24 @@ if [ -f $GITHUB_EVENT_PATH ]; then if [ -z "$BRANCH" ] then # in case of pullresuest event - BRANCH=$(cat $GITHUB_EVENT_PATH | jq -r head.ref) + BRANCH=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.ref) fi else echo "Required file on path 'GITHUB_EVENT_PATH' not exists" fi codefresh auth create-context context --api-key $CF_API_KEY -codefresh auth use-contex context +codefresh auth use-context context +if [ -n "$CF_BRANCH" ] +then + BRANCH=$CF_BRANCH +fi + +echo "Execute pipeline with branch $BRANCH" if [ -n "$TRIGGER_NAME" ] then - codefresh run $PIPELINE_NAME --trigger=$TRIGGER_NAME --branch=$BRANCH + codefresh run $PIPELINE_NAME --trigger=$TRIGGER_NAME --branch=$BRANCH ${@:1} else - codefresh run $PIPELINE_NAME --branch=$BRANCH + codefresh run $PIPELINE_NAME --branch=$BRANCH ${@:1} fi