Triggers

Triggers are events that start workflows in Buildalon, automating routine tasks based on specific actions or schedules. Triggers help streamline development by automatically initiating builds, tests, or deployments whenever key events occur, reducing the need for manual intervention.

Types of Triggers

Push Events

Triggers can be set to activate on push events, such as when code is pushed to a specific branch or when tags are created. This is useful for workflows tied to specific branches (e.g., development, production) or for release builds based on version tags.

Example: Trigger on Push to Specific Branches

on:
  push:
    branches:
      - main
      - development

Pull Request Events

Workflows can be triggered by pull requests, allowing automated actions like testing or code review workflows to start when a pull request is opened, updated, or merged. This ensures that code quality checks are automatically applied to changes before merging.

Example: Trigger on Pull Requests Targeting Specific Branches

on:
  pull_request:
    branches:
      - main
      - development

Scheduled Triggers

Using scheduled triggers, you can configure workflows to run at specific intervals, such as nightly or weekly. Scheduled workflows are helpful for recurring tasks, such as nightly builds or regular integration tests. Cron syntax is used to specify the timing for these schedules.

Example: Trigger on a Scheduled Interval

on:
  schedule:
    - cron: "0 0 * * *"  # Runs every night at midnight

Manual Triggers

Manual triggers enable workflows to be started on-demand through the GitHub Actions interface. This is particularly useful for tasks that don’t need to run automatically but might be needed occasionally, such as a deployment or a maintenance task.

Example: Manual Dispatch

on:
  workflow_dispatch:

Manual triggers also allow input options, which enable users to customize workflow behavior. In Buildalon, the generated workflow includes a clean option that allows developers to start a clean build. To access this option:

  • Go to the Actions tab in your GitHub repository.
  • Select the workflow with a manual trigger.
  • Click Run workflow to open the input options, where you can set the input options.

Example: Manual Dispatch with Input Options

on:
  workflow_dispatch:
    inputs:
      clean:
        description: 'Start a clean build'
        required: false
        default: 'false'

Recommendations

To optimize your workflow setup, we recommend:

  • Push Triggers: Use a push trigger for your primary development branch and release branches. This setup ensures there’s always a “latest” build for your team to test. On top of that, you to go back to older builds to easily find key changes and regressions.
  • Pull Request Triggers: Set up a pull request trigger for changes targeting primary development and release branches. This ensures developers never break the build, and allows your team to test larger changes before they are merged.

Additional Resources

For full documentation on the triggers available in GitHub Actions, see the GitHub Actions Triggers Documentation.

Next Steps

  • Triggers: Set up triggers to start workflows automatically.
  • Build Unity: Set up automated builds for your Unity project.
  • Buildalon Actions: Explore the actions available to use in your workflows.
  • Unit Testing: Automate unit testing to ensure stability and quality.
  • Deploy to Stores: Add deployment steps to distribute your app to users.
  • Dependencies: Learn what to do if your project depends on other private packages or repositories.

© 2024 Virtual Maker Corporation