Sha256: c9c56e4b01aeb18aae166fdb498ebaa757563a6d42ffc9f942cfff88c431baa8

Contents?: true

Size: 1.62 KB

Versions: 23

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

# https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
module KnapsackPro
  module Config
    module CI
      class GithubActions < Base
        def node_total
          # not provided
        end

        def node_index
          # not provided
        end

        def node_build_id
          # A unique number for each run within a repository. This number does not change if you re-run the workflow run.
          ENV['GITHUB_RUN_ID']
        end

        def node_retry_count
          # A unique number for each attempt of a particular workflow run in a repository.
          # This number begins at 1 for the workflow run's first attempt, and increments with each re-run.
          run_attempt = ENV['GITHUB_RUN_ATTEMPT']
          return unless run_attempt
          run_attempt.to_i - 1
        end

        def commit_hash
          ENV['GITHUB_SHA']
        end

        def branch
          # GITHUB_REF - The branch or tag ref that triggered the workflow. For example, refs/heads/feature-branch-1.
          # If neither a branch or tag is available for the event type, the variable will not exist.
          ENV['GITHUB_REF'] || ENV['GITHUB_SHA']
        end

        def project_dir
          ENV['GITHUB_WORKSPACE']
        end

        def user_seat
          ENV['GITHUB_ACTOR']
        end

        def detected
          ENV.key?('GITHUB_ACTIONS') ? self.class : nil
        end

        def fixed_queue_split
          true
        end

        def ci_provider
          "GitHub Actions"
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
knapsack_pro-7.13.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.12.1 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.12.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.11.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.10.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.9.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.8.2 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.8.1 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.8.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.7.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.6.2 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.6.1 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.6.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.1.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.0.1 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-7.0.0 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-6.0.4 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-6.0.3 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-6.0.2 lib/knapsack_pro/config/ci/github_actions.rb
knapsack_pro-6.0.1 lib/knapsack_pro/config/ci/github_actions.rb