/cake-action

:cake::octocat: Run Cake (C# Make) scripts in your GitHub Actions workflows.

Primary LanguageTypeScriptMIT LicenseMIT

Cake for GitHub Actions

GitHub Marketplace GitHub Actions Build GitHub Actions Tests Coveralls

This action allows you to run a Cake script 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. All output from the Cake script will be automatically redirected to the build log for inspection.

Inputs

script-path

If your script is in another location, you can specify the path with the script-path input parameter:

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

target

You'll likely want to specify which task to run out of the ones defined in the Cake script. 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 will run your script using the latest stable version of the Cake .NET Core Global tool. However, if for some reason you want to use a specific version of Cake (for compatibility with older third-party addins, for example), you can do so by specifying the version number in 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, then 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

cake-bootstrap

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

If you're using an older version of Cake, however, you need to explicitly bootstrap them before running the script. The Cake action can take care of 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 do so by setting 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 that the modules will be automatically bootstrapped on Cake 1.0.0 or later.

Cross-platform

Since the Cake Tool is 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.