Automate workflows with GitHub Actions

4 minute readDeveloper productivity

GitHub Actions help you automate your development workflow.

CloudBees CD/RO GitHub Actions are available on the GitHub Marketplace. 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 CD/RO GitHub Actions overview

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

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-actions/run-procedure

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

cloudbees-github-actions/run-pipeline

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

cloudbees-github-actions/run-process

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

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 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, or send an inquiry about an instance to your dedicated CloudBees Customer Success Manager.

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

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.

    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 CD/RO GitHub Actions are implemented

Go to the 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 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.

Want to know more?

Below are links to some helpful resources.