Skip to content

Commit

Permalink
Merge pull request #1 from Taucher2003/support-pull-request-events
Browse files Browse the repository at this point in the history
Add support for pull request events
  • Loading branch information
Taucher2003 authored Nov 14, 2023
2 parents ef82f0f + 4f0db4d commit 267e05f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/action/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module GitlabPipelineAction
class Context
attr_accessor :gh_project, :gh_sha, :gh_ref, :gh_server_url,
attr_accessor :gh_project, :gh_sha, :gh_ref, :gh_ref_name, :gh_server_url,
:gl_server_url, :gl_project_id, :gl_project_path, :gl_runner_token,
:gl_api_token, :gl_pipeline,
:git_repository, :git_path,
Expand Down
3 changes: 2 additions & 1 deletion lib/action/step/clone_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ def execute
context.git_path
)

context.git_repository.fetch('origin', ref: context.gh_ref)
context.git_repository.checkout(context.gh_sha)
context.git_repository.branch(context.gh_ref).checkout
context.git_repository.branch(context.gh_ref_name).checkout
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/action/step/prepare_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class PrepareContext < Base
def execute
context.gh_project = ENV.fetch('GITHUB_REPOSITORY', nil)
context.gh_sha = ENV.fetch('GITHUB_SHA', nil)
context.gh_ref = ENV.fetch('GITHUB_REF_NAME', nil)
context.gh_ref = ENV.fetch('GITHUB_REF', nil)
context.gh_ref_name = ENV.fetch('GITHUB_REF_NAME', nil)
context.gh_server_url = ENV.fetch('GITHUB_SERVER_URL', nil)

context.gl_server_url = ENV.fetch('INPUT_GL_SERVER_URL', nil)
Expand Down
2 changes: 1 addition & 1 deletion lib/action/step/push_branch_to_gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Step
class PushBranchToGitlab < Base
def execute
context.git_repository.add_remote(GITLAB_REMOTE, gitlab_remote_url)
context.git_repository.push(GITLAB_REMOTE, context.gh_ref, push_option: ['ci.skip'])
context.git_repository.push(GITLAB_REMOTE, context.gh_ref_name, push_option: ['ci.skip'])
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/action/step/remove_branch_from_gitlab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module GitlabPipelineAction
module Step
class RemoveBranchFromGitlab < Base
def execute
context.gitlab_client.delete_branch(context.gl_project_id, context.gh_ref)
context.gitlab_client.delete_branch(context.gl_project_id, context.gh_ref_name)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/action/step/trigger_pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TriggerPipeline < Base
def execute
context.gl_pipeline = context.gitlab_client.create_pipeline(
context.gl_project_id,
context.gh_ref
context.gh_ref_name
)

puts "Triggered: #{context.gl_pipeline.web_url}"
Expand Down

0 comments on commit 267e05f

Please sign in to comment.