Class: GithubActions::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/github_actions/github_actions/workflow.rb

Overview

Github Actions workflow

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Workflow

load the workflow from an YAML file

Parameters:

  • file (String)

    path to the YAML file



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 39

def initialize(file)
  @file = file
  yml = YAML.load_file(file)
  @name = yml["name"]
  # "on" is autoconverted to Boolean "true" for this line
  #   on: [push, pull_request]
  # see https://medium.com/@lefloh/lessons-learned-about-yaml-and-norway-13ba26df680
  @on = yml[true]

  @jobs = yml["jobs"].map do |name, job|
    Job.new(name, job, self)
  end
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



27
28
29
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27

def file
  @file
end

#jobsObject (readonly)

Returns the value of attribute jobs.



27
28
29
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27

def jobs
  @jobs
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27

def name
  @name
end

#onObject (readonly)

Returns the value of attribute on.



27
28
29
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 27

def on
  @on
end

Class Method Details

.readArray<GithubActions::Workflow>

load all defined workflows from all YAML files

Returns:



31
32
33
34
35
# File 'lib/tasks/github_actions/github_actions/workflow.rb', line 31

def self.read
  Dir[".github/workflows/*.{yml,yaml}"].map do |file|
    new(file)
  end
end