Skip to content
matlab-actions

GitHub Action

Run MATLAB Build

v2.2.1 Latest version

Run MATLAB Build

matlab-actions

Run MATLAB Build

Run a build with the MATLAB build tool

Installation

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

              

- name: Run MATLAB Build

uses: matlab-actions/run-build@v2.2.1

Learn more about this action in matlab-actions/run-build

Choose a version

Action for Running MATLAB Builds

Starting in R2022b, the MATLAB® build tool provides a standard programming interface to create and run software-build tasks in a uniform and efficient way. For example, you can create tasks that identify code issues, run tests, and package a toolbox in a single build file in your project root folder, and then invoke the build tool to run these tasks. For more information, see Overview of MATLAB Build Tool.

The Run MATLAB Build action enables you to invoke the MATLAB build tool on a self-hosted or GitHub®-hosted runner. The action uses the topmost MATLAB version on the system path.

Examples

Use the Run MATLAB Build action to run a build using the MATLAB build tool. You can use this action to run the tasks specified in a file named buildfile.m in the root of your repository. To use the Run MATLAB Build action, you need MATLAB R2022b or a later release.

Run MATLAB Build on Self-Hosted Runner

Use a self-hosted runner to run the default tasks in your build plan as well as all the tasks on which they depend.

name: Run MATLAB Build on Self-Hosted Runner
on: [push]
jobs:
  my-job:
    name: Run MATLAB Build
    runs-on: self-hosted
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
      - name: Run build
        uses: matlab-actions/run-build@v2

Run MATLAB Build on GitHub-Hosted Runner

Before you run MATLAB code or Simulink models on a GitHub-hosted runner, first use the Setup MATLAB action. The action sets up your specified MATLAB release (R2021a or later) on a Linux®, Windows®, or macOS runner. If you do not specify a release, the action sets up the latest release of MATLAB.

For example, set up the latest release of MATLAB on a GitHub-hosted runner, and then use the Run MATLAB Build action to run a specific task and the tasks on which it depends.

name: Run MATLAB Build on GitHub-Hosted Runner
on: [push]
jobs:
  my-job:
    name: Run MATLAB Build
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v4
      - name: Set up MATLAB
        uses: matlab-actions/setup-matlab@v2
      - name: Run build
        uses: matlab-actions/run-build@v2
        with:
          tasks: mytask

Run MATLAB Build

When you define your workflow in the .github/workflows directory of your repository, specify the Run MATLAB Build action as matlab-actions/run-build@v2. The action accepts optional inputs.

Input Description
tasks

(Optional) Tasks to run, specified as a list of task names separated by spaces. If a task accepts arguments, enclose them in parentheses. If you do not specify tasks, the action runs the default tasks in buildfile.m as well as all the tasks on which they depend.

MATLAB exits with exit code 0 if the tasks run without error. Otherwise, MATLAB terminates with a nonzero exit code, which causes the action to fail.

Example: tasks: test
Example: tasks: compile test
Example: tasks: check test("myFolder",OutputDetail="concise") archive("source.zip")

build-options

(Optional) MATLAB build options, specified as a list of options separated by spaces. The action supports the same options that you can pass to the buildtool command.

Example: build-options: -continueOnFailure
Example: build-options: -continueOnFailure -skip test

startup-options

(Optional) MATLAB startup options, specified as a list of options separated by spaces. For more information about startup options, see Commonly Used Startup Options.

Using this input to specify the -batch or -r option is not supported.

Example: startup-options: -nojvm
Example: startup-options: -nojvm -logfile output.log

When you use this action, a file named buildfile.m must be in the project root directory.

Notes

  • By default, when you use the Run MATLAB Build action, the root of your repository serves as the MATLAB startup folder. To run your MATLAB build using a different folder, include the -sd startup option in the action.
  • The Run MATLAB Build action uses the -batch option to invoke the buildtool command. Preferences do not persist across different MATLAB sessions launched with the -batch option. To run code that requires the same preferences, use a single action.
  • When you use the Run MATLAB Build action, you execute third-party code that is licensed under separate terms.

See Also

Contact Us

If you have any questions or suggestions, please contact MathWorks® at continuous-integration@mathworks.com.