# Automate workflows with GitHub Actions

Automate workflows with GitHub Actions
======================================

GitHub Actions help you automate your development workflow.

CloudBees CD/RO GitHub Actions are available on the [GitHub Marketplace](https://github.com/marketplace?type=actions&query=cloudbees-github-actions). These actions enable you to run CloudBees CD/RO operations, such as running a pipeline or applying DSL from a GitHub Action workflow. You can easily create your own custom CloudBees CD/RO GitHub Actions by leveraging the 'eval-dsl\` action, which is the basis for all the other CloudBees CD/RO GitHub Actions.

[](#_the_cloudbees_cdro_github_actions_overview)The CloudBees CD/RO GitHub Actions overview
-------------------------------------------------------------------------------------------

This section provides an overview of the CloudBees CD/RO GitHub Actions.

### [](#_cloudbees_github_actionseval_dsl)cloudbees-github-actions/eval-dsl

This action enables workflows to send DSL (Domain Specific Language) to a CloudBees CD/RO server for evaluation. The DSL can create entities in the server, such as `procedure` and `release` models. In addition, the DSL has full access to the CloudBees CD/RO API; for example, `getProjects()` returns a list of all projects in the system. This GitHub Action can be used in a workflow or called in a `composite` GitHub Action definition. The latter approach was used to implement the other CloudBees CD/RO GitHub Actions such as `run-procedure` and `start-release.`

### [](#_cloudbees_github_actionsrun_procedure)cloudbees-github-actions/run-procedure

This action enables workflows to run an existing procedure on a remote CloudBees CD/RO instance.

### [](#_cloudbees_github_actionsrun_pipeline)cloudbees-github-actions/run-pipeline

This action enables workflows to run an existing pipeline on a remote CloudBees CD/RO instance.

### [](#_cloudbees_github_actionsrun_process)cloudbees-github-actions/run-process

This action enables workflows to run an existing application process on a remote CloudBees CD/RO instance.

### [](#_cloudbees_github_actionscreate_release_from_template)cloudbees-github-actions/create-release-from-template

This action enables workflows to create a release from an existing template on a remote CloudBees CD/RO instance.

[](#_get_started_with_cloudbees_cdro_github_actions)Get started with CloudBees CD/RO GitHub Actions
---------------------------------------------------------------------------------------------------

Start here. Progress through each of the following sections.

1.  Watch the overview video to get acquainted with CloudBees CD/RO GitHub Actions.
    
2.  View a complete example to see how it works and gain hands-on experience.
    
3.  Explore how CloudBees CD/RO GitHub Actions are implemented.
    
4.  Add a CloudBees CD/RO GitHub Action to your workflow.
    

To add a CloudBees CD/RO GitHub Action in one of your workflows, you need access to a CloudBees CD/RO instance that can accept REST calls from GitHub. If you are new to CloudBees CD/RO start here: [How the evaluation works](/docs/cloudbees-cdro-eval/latest/eval/), or send an inquiry about an instance to your dedicated CloudBees Customer Success Manager.

### [](#_get_acquainted_with_cloudbees_cdro_github_actions)Get acquainted with CloudBees CD/RO GitHub Actions

Watch a quick video about the CloudBees CD/RO GitHub Actions demonstration repository that illustrates how to use CloudBees CD/RO GitHub Actions to deploy and release an application.

*   View the CloudBees CD/RO GitHub Actions overview video \[coming soon\].
    

### [](#_view_a_complete_example_to_see_how_it_works)View a complete example to see how it works

Locate and review the CloudBees CD/RO GitHub Actions demonstration repository. This repository provides the source code, Dockerfile, and GitHub Actions Workflows to build a simple deployable application and release it to production with CloudBees CD/RO.

*   Access the [CloudBees CD/RO GitHub Actions demonstration repository](https://github.com/cloudbees-demos/gh-actions-demo).  
    
    View a sample code block from the demonstration repository.
    
        name: Build and deploy
        on:
          push:
            branches:
              - main
            paths-ignore:
              - "platform_content/**"
              - ".github/workflows/cd-setup.yaml"
          pull_request:
            branches:
              - main
          workflow_dispatch:
        env:
          GO_VERSION: "1.20.6"
          APP_NAME: demo-app
        jobs:
          build:
            runs-on: ubuntu-latest
        
            steps:
              - name: Checkout code
                uses: actions/checkout@v3
        
              - name: Setup Go
                uses: actions/setup-go@v3
                with:
                  go-version: ${{ env.GO_VERSION }}
        
              - name: Install dependencies
                run: go mod download
        
              - name: Run tests
                run: go test -v ./...
        
              - name: Run build
                run: go build -v
        
              - name: Login to Docker Hub
                uses: docker/login-action@v2
                with:
                  username: ${{ secrets.DOCKERHUB_USER }}
                  password: ${{ secrets.DOCKERHUB_TOKEN }}
        
              - name: Build and push container
                uses: docker/build-push-action@v3
                with:
                  context: .
                  push: true
                  tags: ${{ secrets.DOCKERHUB_USER }}/${{ env.APP_NAME }}:${{ github.sha }}
        
              - name: Kick off CD/RO application deploy
                if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
                env:
                  CDRO_URL: ${{ secrets.CDRO_URL }}
                  CDRO_TOKEN: ${{ secrets.CDRO_TOKEN }}
                uses: cloudbees-github-actions/run-process@v1
                with:
                  projectName: GHA
                  applicationName: Demo App
                  processName: Deploy Application
                  environmentName: demo-dev
                  actualParameter: |
                    imageTag: ${{ github.sha }}
                    imageRepository: ${{ secrets.DOCKERHUB_USER }}/${{ env.APP_NAME }}
        
              - name: Create release from template
                if: github.event_name == 'push' && github.ref == 'refs/heads/main'
                env:
                  CDRO_URL: ${{ secrets.CDRO_URL }}
                  CDRO_TOKEN: ${{ secrets.CDRO_TOKEN }}
                uses: cloudbees-github-actions/create-release-from-template@v1
                with:
                  templateProjectName: GHA
                  templateCatalogName: GHA
                  templateName: Simple Release
                  actualParameter: |
                    releaseName: "Simple Release ${{ github.sha }}"
                    imageTag: "${{ github.sha }}"
                    imageRepository: ${{ secrets.DOCKERHUB_USER }}/${{ env.APP_NAME }}
        
              - name: Run release
                if: github.event_name == 'push' && github.ref == 'refs/heads/main'
                env:
                  CDRO_URL: ${{ secrets.CDRO_URL }}
                  CDRO_TOKEN: ${{ secrets.CDRO_TOKEN }}
                uses: cloudbees-github-actions/start-release@v1
                with:
                  projectName: GHA
                  releaseName: Simple Release ${{ github.sha }}
    

### [](#_explore_how_cloudbees_cdro_github_actions_are_implemented)Explore how CloudBees CD/RO GitHub Actions are implemented

Go to the [cloudbees-github-actions](https://github.com/cloudbees-github-actions) repository and locate the README file for `eval-dsl` (Evaluate DSL on a remote CloudBees CD/RO instance). Read the README file to familiarize yourself with the project details, usage guidance, requirements, example code, and more.

The `eval-dsl` Action is one of several GitHub Actions provided on an "as-is" basis by CloudBees to enable users to write GitHub Action Workflows that send work to an external CloudBees CD/RO instance.

### [](#_add_a_cloudbees_cdro_github_action_to_your_workflow)Add a CloudBees CD/RO GitHub Action to your workflow

To use these CloudBees CD/RO GitHub Actions in your own repository workflows, edit one of your workflows. When prompted to select an action from the Marketplace, type in “cd/ro” to find one of these actions. Select one and use `copy` and `paste` to insert it into your workflow. You also have to provide the two CDRO\_ environment variables. Refer to the `CDRO_URL:` and `CDRO_TOKEN:` syntax in the code block below:

    steps:
      - name: Run EvalDSL Action
        uses: cloudbees-github-actions/eval-dsl@v1
        env:
          CDRO_URL: '${{ secrets.CDRO_URL }}'
          CDRO_TOKEN: '${{ secrets.CDRO_TOKEN }}'
        with:
          dsl-file: ./example-dsl.groovy
          dsl-args: |
            projectName: My project
            projectDescription: My project description
            procedureName: My procedure
          dsl-actual-parameter: |
            procedureInput1: 123
            procedureInput2: abc

Access the above codeblock from [cloudbees-github-actions/eval-dsl](https://github.com/cloudbees-github-actions/eval-dsl#usage).

[](#_want_to_know_more)Want to know more?
-----------------------------------------

Below are links to some helpful resources.

*   [Understanding GitHub Actions](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions)