ca6a1f33f9
Detect if pipeline runs for a GitHub pull request When using a mirror for CI/CD only we register a pull_request webhook. When a pull_request webhook is received, if the source branch SHA matches the actual head of the branch in the repository we create immediately a new pipeline for the external pull request. Otherwise we store the pull request info for when the push webhook is received. When using "only/except: external_pull_requests" we can detect if the pipeline has a open pull request on GitHub and create or not the job based on that.
41 lines
874 B
Ruby
41 lines
874 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Ci
|
|
module PipelineEnums
|
|
# Returns the `Hash` to use for creating the `failure_reason` enum for
|
|
# `Ci::Pipeline`.
|
|
def self.failure_reasons
|
|
{
|
|
unknown_failure: 0,
|
|
config_error: 1
|
|
}
|
|
end
|
|
|
|
# Returns the `Hash` to use for creating the `sources` enum for
|
|
# `Ci::Pipeline`.
|
|
def self.sources
|
|
{
|
|
unknown: nil,
|
|
push: 1,
|
|
web: 2,
|
|
trigger: 3,
|
|
schedule: 4,
|
|
api: 5,
|
|
external: 6,
|
|
chat: 8,
|
|
merge_request_event: 10,
|
|
external_pull_request_event: 11
|
|
}
|
|
end
|
|
|
|
# Returns the `Hash` to use for creating the `config_sources` enum for
|
|
# `Ci::Pipeline`.
|
|
def self.config_sources
|
|
{
|
|
unknown_source: nil,
|
|
repository_source: 1,
|
|
auto_devops_source: 2
|
|
}
|
|
end
|
|
end
|
|
end
|