Connect your GitHub Actions pipelines to Codefresh
Codefresh Hosted GitOps can be used with any popular Continuous Integration (CI) solution, not just with Codefresh CI.
You can connect any external CI solution to Codefresh, such as GitHub Actions for example, to take care of common CI tasks such as building/testing/scanning source code, with Codefresh Hosted GitOps still responsible for the deployment, including image enrichment and reporting.
See Image enrichment with integrations.
Codefresh Marketplace GitHub Action
To support the integration between GitHub Actions and Codefresh, they have created a dedicated action in the Codefresh marketplace. The action combines image enrichment and reporting through integrations with Jira, and container registries such as DockerHub or Quay.
Use the action in the following manner:
- Create a GitHub Actions pipeline like you normally do.
- Use any existing CI actions for compiling code, running unit tests, security scanning etc.
- Place the final action in the pipeline as the “report image” action provided by Codefresh, copying the arguments and values from the GitHub Actions integration you set up in Codefresh.
- When the pipeline completes execution, Codefresh retrieves the information on the image that was built and its metadata (essentially the same data that Codefresh CI would send automatically).
- View the image in Codefresh in the Images dashboard, and in any GitOps deployment in which it is used.
Codefresh-GitHub Action integration arguments
The table describes the arguments required for GitHub Action-Codefresh integration.
||The URL to the cluster with the Codefresh runtime to integrate with. If you have more than one runtime, select the runtime from the list. Codefresh displays the URL of the selected runtime cluster.||Required|
||The API key to authenticate the GitHub Actions user to Codefresh. Generate the key for the GitHub Action.||Required|
||The name of the registry integration created in Codefresh to use with the GitHub Action.||Optional|
||The name of the Jira integration created in Codefresh to use for the GitHub Action. Relevant only if Jira enrichment is required for the image. If you don’t have a Jira integration, create a new integration (see Jira integration). When defined,
||The name of the image to report to Codefresh.||Required|
||The type or types of enrichment information to retrieve and add to the image. By default, empty. When enrichment information is required, can be either
||The reported URL of the workflow that builds the image.||Optional|
||The name assigned to the workflow that builds the image. When defined, the name is displayed in the Codefresh platform. Example,
||The token for Git integration.||Required|
||Relevant only when
||Relevant only when
Connect a GitHub Action in Codefresh
Add a GitHub Action to Codefresh with the required arguments.
- In the Codefresh UI, go to Integrations.
- Select GitHub Actions, and then click Configure.
- Define the arguments for the GitHub Action. Review GitHub Action arguments.
- For the CF_API_KEY, click Generate. Note down the token generated.
- To create a container registry integration for DockerHub if you don’t have one, click Create Container Registry Integration, and then configure the settings. See Docker Hub integration.
- To create a Jira integration, click Create Atlassian Jira Integration, and then configure the settings. See Jira integration.
- Enter this token in GitHub Actions as a secret with the name
Now you can reference it in all GitHub pipelines as you would any other secret.
- Copy the arguments and their values to the GitHub Action pipeline. See the example below for guidelines.
GitHub Actions pipeline example
Here is an example pipeline that uses GitHub Actions to build a container image, and the Codefresh action to enrich and report the resulting image to Codefresh.
Because a Jira integration account is configured in Codefresh, the step needs only the name for
CF_JIRA_INTEGRATION, instead of explicit credentials
GitHub Action logs
View and analyze logs for GitHub Action workflows through the Logs tab. When a GitHub Action is run, it is added to the Logs tab.
- Filter by status or by date range to view a subset of actions
- Navigate to the build file in GitHub Actions, and view the Codefresh report image step
Build YAML in GitHub Action
The Run column includes the link to the build files for the actions.
Here are examples of the build file for the GitHub Action (top) and of the Codefresh report image step in the action (below).