github_actions_toolkit 0.0.5

Dart native
Flutter Android iOS

Toolkit containing useful methods to build a GitHub Action with Dart.

github_actions_toolkit #

A third-party toolkit for GitHub Actions coded in Dart. It is inspired by the official Javascript actions/toolkit and contains similar commands.

Check out this "Hello World" Action for a complete example of a Dart GitHub Action.

Usage #

Logging #

Logging commands are available under log.

There are four levels:

  • error
  • warning
  • info
  • debug

Logs with info level will have no particular emphasis and be directly transmitted to stdout.

Logs with debug level will only appear if the secret ACTIONS_STEP_DEBUG has been created in the repository with the value true (see "Creating and using encrypted secrets").

import 'package:github_actions_toolkit/github_actions_toolkit.dart' as gaction;

main() async {
  const logger = gaction.log;
  logger'This is just a message')
    ..warning('This is a warning message')
    ..error('This is an error message');

  // [isDebug] is true iff the secret `ACTIONS_STEP_DEBUG` has been configured
  final message = gaction.isDebug
      ? 'This is a debug message'
      : 'This is a debug message that you will not see';

Inputs #

Create an Input object for each input that your action needs, and retrieve their value with the value getter.

This getter will throw an ArgumentError if the input had been set as required and is missing.

import 'package:github_actions_toolkit/github_actions_toolkit.dart' as gaction;

main() async {
  const input = gaction.Input(
    'who-to-greet', // name defined in the YAML file
    isRequired: true,

    .info('Hello ${input.value}!');

Outputs #

Set an output for subsequent steps with setOutput.

Subprocesses #

Execute a command in the shell with the exec function. It will return an ExecResult object once the command has terminated with its exit code and its outputs.

import 'package:github_actions_toolkit/github_actions_toolkit.dart' as gaction;

main() async {
  final process = await gaction.exec('echo', ['Hello world']);

    .info("The 'echo' command has terminated with code ${process.exitCode} and has printed ${process.stdout}");

Features and bugs #

Please file feature requests and bugs at the issue tracker.

pub points

Toolkit containing useful methods to build a GitHub Action with Dart.

Repository (GitHub)
View/report issues


API reference





meta, synchronized


Packages that depend on github_actions_toolkit