Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix branches with a common prefix for this action #10

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/action/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

module GitlabPipelineAction
class Context
attr_accessor :gh_project, :gh_sha, :gh_ref, :gh_ref_name, :gh_server_url,
attr_accessor :gh_project, :gh_sha, :gh_ref, :gh_server_url,
:gl_server_url, :gl_project_id, :gl_project_path, :gl_runner_token,
:gl_api_token, :gl_pipeline,
:gl_api_token, :gl_pipeline, :gl_branch_name,
:git_repository, :git_path,
:gitlab_client,
:docker_runner_container
Expand Down
2 changes: 1 addition & 1 deletion lib/action/step/clone_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def execute

context.git_repository.fetch('origin', ref: context.gh_ref)
context.git_repository.checkout(context.gh_sha)
context.git_repository.branch(context.gh_ref_name).checkout
context.git_repository.branch(context.gl_branch_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 @@ -7,9 +7,10 @@ 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', nil)
context.gh_ref_name = ENV.fetch('GITHUB_REF_NAME', nil)
context.gh_server_url = ENV.fetch('GITHUB_SERVER_URL', nil)

context.gl_branch_name = "glpa/#{ENV.fetch('GITHUB_REF_NAME', nil)}"

context.gl_server_url = ENV.fetch('INPUT_GL_SERVER_URL', nil)
context.gl_project_id = ENV.fetch('INPUT_GL_PROJECT_ID', nil)
context.gl_runner_token = ENV.fetch('INPUT_GL_RUNNER_TOKEN', 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_name, push_option: ['ci.skip'])
context.git_repository.push(GITLAB_REMOTE, context.gl_branch_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_name)
context.gitlab_client.delete_branch(context.gl_project_id, context.gl_branch_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_name
context.gl_branch_name
)

puts "Triggered: #{context.gl_pipeline.web_url}"
Expand Down
10 changes: 0 additions & 10 deletions test/await_healthy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,3 @@ echo "GitLab is healthy at $GITLAB_BASE_URL"
curl --silent --show-error --header "Private-Token: TEST1234567890123456" "$GITLAB_BASE_URL/api/v4/version"

echo
printf 'Waiting for Test project to be imported'

import_status=""
while [[ "$import_status" != "finished" ]]; do
printf '.'
import_status=$(curl --silent --show-error --header "Private-Token: TEST1234567890123456" "$GITLAB_BASE_URL/api/v4/projects/1000" | jq -r .import_status)
sleep 5
done

echo
5 changes: 0 additions & 5 deletions test/healthcheck_and_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ test -f $done || {
printf ').execute;'

printf 'while project.reload.import_status != "finished"; sleep 5; end;'
printf 'Projects::UpdateService.new('
printf 'project,'
printf 'Users::Internal.admin_bot,'
printf 'default_branch: "testing-project-default-branch"'
printf ').execute'
) | gitlab-rails console

touch $done
Expand Down