Skip to content
box

GitHub Action

Cake Action

v2.0.0 Latest version

Cake Action

box

Cake Action

Run a Cake script as part of your build

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Cake Action

uses: cake-build/[email protected]

Learn more about this action in cake-build/cake-action

Choose a version

Cake for GitHub Actions

GitHub Marketplace GitHub Actions Build GitHub Actions Tests Coveralls

This action allows you to run a Cake script or Cake Frosting project from your GitHub Actions workflow without having to use a bootstrapper.

Usage

Using the Cake action from a GitHub Actions workflow is as simple as referencing this repository from a build step:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2

The Cake action will look for a script named build.cake in your repository's root directory and run it for you using the Cake Tool. You can also specify the path to your Cake script using the script-path option. If you are using a Cake Frosting project instead, you must specify the path to your .csproj file with the project-path parameter.

All output from the Cake script or Cake Frosting project is automatically redirected to the build log for inspection.

Inputs

script-path

If your Cake script is located somewhere other than the root directory of your project, you can specify its path using the script-path input parameter:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      script-path: path/to/script.cake

project-path

If you are using Cake Frosting, you must specify the path to the project file with the project-path input parameter:

steps:
  - name: Run Cake Frosting
    uses: cake-build/cake-action@v2
    with:
      project-path: path/to/build.csproj

target

You'll likely want to specify which task to run out of the ones defined in the Cake script or Cake Frosting project. For that, you can use the target parameter:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      target: Task-To-Run

verbosity

You can adjust the amount of information Cake sends to the build log by changing the verbosity level with the verbosity parameter:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      verbosity: Diagnostic

The supported verbosity levels are Quiet, Minimal, Normal, Verbose and Diagnostic. The default level is set to Normal.

dry-run

While developing a script, you'll sometimes want to see which tasks would be triggered by a given target without actually running them. That's exactly what the dry-run parameter is for:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      dry-run: true

When dry-run is set to true, Cake will print out the names of the tasks to run according to the dependency graph, but it won't perform any of the instructions defined in them.

arguments

If your script defines any custom parameters, you can specify arguments for them by using the arguments parameter:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      arguments: |
        name: value
        configuration: Release

The arguments are defined in a multi-line string literal where each argument is on a separate line in the format name: value. Keep in mind that the values you specify here are passed as is to the Cake script; this means that characters like quotes are kept intact (for example, name: 'value' will result in --name='value' being passed to the script).

cake-version

By default, the Cake action runs your script using the latest stable version of the Cake .NET Core Global tool.

If you need to use a specific version of Cake (e.g. for compatibility with older addins), you can specify it with the cake-version parameter:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      cake-version: 0.30.0

If you're pinning your Cake version using a tool manifest file, you can have the action restore any local tools, including Cake, by specifying tool-manifest as the argument for cake-version:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      cake-version: tool-manifest

ℹ️ This option is ignored when using Cake Frosting projects.

cake-bootstrap

As of Cake 1.0.0, any custom modules that you reference in your script are bootstrapped automatically upon running it.

For older versions of Cake, you need to explicitly bootstrap any referenced modules before running the script. The Cake action can handle this extra step for you by setting the cake-bootstrap parameter to explicit:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      cake-bootstrap: explicit
      cake-version: 0.38.5

If you're using Cake 1.0.0 or later and wish to opt out of the automatic bootstrapping of modules, you can set the cake-bootstrap parameter to skip:

steps:
  - name: Run the Cake script
    uses: cake-build/cake-action@v2
    with:
      cake-bootstrap: skip

The default value is auto, which means modules will be automatically bootstrapped on Cake 1.0.0 or later.

ℹ️ This option is ignored when using Cake Frosting projects.

Cross-platform

Since the Cake Tool and Cake Frosting are built on .NET Core, the Cake action will run on any of the virtual environments supported by GitHub Actions, namely Linux, Windows and macOS.

This allows you to define your build step exactly once and run it on multiple operating systems in parallel by defining a build matrix:

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest, macOS-latest]
    steps:
      - name: Get the sources
        uses: actions/checkout@v1
      - name: Run the build script
        uses: cake-build/cake-action@v2
        with:
          target: Build

You can read more about how to define a build matrix in the workflow syntax for GitHub Actions.