View Source GitHubActions.Config (GitHubActions v0.2.20)

A simple keyword-based configuration API.

Examples

This module is used to define the configuration for GitHubActions.

import GitHubActions.Config

config :linux,
  name: "Ubuntu",
  runs_on: "ubuntu-20.04"

config key: "value"

Summary

Functions

Returns the configuration.

Adds the given data to the configuration.

Adds the given value to the configuration under the given key.

Returns the value for key or keys in a tuple.

Returns the value for key or keys.

Returns the value for key or keys.

Reads the configuration from the given path.

Types

@type config() :: keyword()
@type key() :: atom()
@type keys() :: [atom()]
@type value() :: any()

Functions

@spec config() :: config()

Returns the configuration.

@spec config(config()) :: config() | nil

Adds the given data to the configuration.

Returns the configuration that was previously stored.

@spec config(key(), value()) :: config() | nil

Adds the given value to the configuration under the given key.

Returns the configuration that was previously stored.

@spec fetch(key() | keys()) :: value()

Returns the value for key or keys in a tuple.

If the configuration parameter does not exist, the function returns error.

Examples

iex> Config.fetch(:jobs)
{:ok, [:linux]}

iex> Config.fetch(:foo)
:error

iex> Config.fetch([:linux, :name])
{:ok, "Ubuntu"}
@spec fetch!(key() | keys()) :: value()

Returns the value for key or keys.

Examples

iex> Config.fetch!(:jobs)
[:linux]

iex> Config.fetch!([:linux, :runs_on])
"ubuntu-20.04"

iex> Config.fetch!([:linux, :foo])
** (KeyError) key :foo not found in: [name: "Ubuntu", runs_on: "ubuntu-20.04"]
Link to this function

get(keys, default \\ nil)

View Source
@spec get(key() | keys(), value()) :: value()

Returns the value for key or keys.

If the configuration parameter does not exist, the function returns the default value.

Examples

iex> Config.get(:jobs)
[:linux]

iex> Config.get(:foo, :bar)
:bar

iex> Config.get([:linux, :runs_on])
"ubuntu-20.04"

iex> Config.get(:foo)
nil
@spec read(Path.t()) :: :ok | {:error, :enonet}

Reads the configuration from the given path.