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

feat: add new local_archive update code strategy #3906

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

calebdw
Copy link

@calebdw calebdw commented Oct 1, 2024

  • Bug fix #…?
  • New feature?
  • BC breaks?
  • Tests added?
  • Docs added?

Hello!

Description

This adds a new local_archive update code strategy which creates a tar from the local repository that is then streamed to the remote server and unpacked. This removes the need for the remote server to fetch the changes from the remote repository.

Motivation

We have a privately hosted Gitlab instance, and we deploy to cloud servers via our ci/cd pipelines. This has been working just fine in the past. However, we've recently encountered an issue where the external server is not able to connect via ssh to the internal Gitlab server---which means the git remote update fails and our deployments are failing. The root issue is non-trivial and our IT personnel has been working with Cisco techs for a couple of weeks now, but they still have not been able to fix the issue.

I temporarily fixed our deployments by overriding the deploy:update_code task to simply use the local repository in the pipeline which works perfectly:

task('deploy:update_code', function () {
    $host = currentHost()->connectionString();
    $target = get('target');

    $targetWithDir = $target;
    if (!empty(get('sub_directory'))) {
        $targetWithDir .= ':{{sub_directory}}';
    }

    runLocally(<<<BASH
        git archive {$targetWithDir} | ssh {$host} "tar -x -f - -C {{release_path}} 2>&1"
        BASH);

    $rev = escapeshellarg(runLocally("git rev-list $target -1"));
    run("echo $rev > {{release_path}}/REVISION");
});

I figured it would be a good idea to contribute this upstream in case anyone else would like to use this strategy :)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant