Calling Codefresh pipelines from Github actions

Calling Codefresh pipelines from Github actions

3 min read

At Codefresh we are all about collaboration and reusing existing standards instead of implementing proprietary solutions. A Codefresh pipeline is based on a series of Docker containers that act as individual steps. All Codefresh plugins are also just Docker images which means that extending a Codefresh pipeline is the same thing as writing a Dockerfile.

Github has recently announced an integrated automation solution called Actions. Using Github actions you can easily trigger automated workflows on Git events (such as push). It is also easy to create your own action. You can do so in two ways, either as a Docker image or with Javascript.

Of course, we are very happy to see that Github actions can be created with Docker images. This is the exact same model that Codefresh is using for plugins/steps and it means that a developer can create a Github action using any programming language and tool as long as it is packaged in a Docker container.

Creating a Dockerized Github Action

To showcase how dockerized Github actions work we created an action on our own which is open-source and also available in the Github marketplace.

The Codefresh action allows you to launch Codefresh pipelines from Github workflows. The action allows one to use Codefresh as the backend that does the heavy lifting of deployment while Github serves as the trigger, depending on which action you monitor.

This means that you get the best of both worlds. Easy integration with a Github repository and Github permissions (Codefresh also supports Github repositories natively after authenticating with Github) while still getting access to the Codefresh pipeline capabilities and DevOps insight dashboards.

Helm environment board
Helm environment board

You can see a real example of using the action in our own yaml validator project:

name: run codefresh pipeline
on: push
jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
      - name: Codefresh pipeline runner
        uses: codefresh-io/codefresh-pipeline-runner@v5
        env:
          PIPELINE_NAME: 'codefresh-io/cf-yaml-validator/cf-yaml-validator'
          TRIGGER_NAME: 'codefresh-io/cf-yaml-validator_1'
          CF_API_KEY: ${{ secrets.CF_API_KEY }}
        id: run-pipeline

The parameters needed are the name of the pipeline that you want to call, which trigger to use, and your Codefresh token.

The Token can be stored as a standard Github secret in your Github account settings. That’s it! Now every time you push on your Github repository, the respective Codefresh pipeline will automatically run. It is also possible to launch multiple Codefresh pipelines in this manner.

Reusing Github actions as Codefresh plugins

The most interesting aspect of Github actions as Docker images is the huge potential for reusing plugins between the two platforms. Codefresh plugins can be used as Github actions and vice-versa.

This means that Codefresh gains access to the 40 million Github developers as prospective plugin writers since any Github action is automatically available as a Codefresh plugin. This interoperability paradigm certainly changes the number of plugins available for Codefresh pipelines.

This is already evident by the Github Action marketplace at: https://github.com/marketplace?type=actions . Any of those actions (that are Docker-based) can be used in a Codefresh pipeline as well. The actions marketplace is already filled with more than 800 actions such as:

All Github actions from the community can now be used in Codefresh pipelines and we couldn’t be more happy about it 🙂

The Codefresh/Github action we just released is ready to be used in your Github workflows today. If you have any suggestions or comments the code is fully open-source. We are preparing another major announcement for Github actions and Codefresh collaboration. Stay tuned for our next blog post.

Ready to try Codefresh and start creating your own CI/CD pipelines for microservices? Create Your Free Account Today!

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Build your GitOps skills and credibility today with a GitOps Certification.

Get GitOps Certified

Ready to Get Started?
  • safer deployments
  • More frequent deployments
  • resilient deployments