Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: add new local_archive update code strategy #3906

Closed
wants to merge 1 commit into 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!

@antonmedv antonmedv closed this Feb 10, 2025
@calebdw
Copy link
Author

calebdw commented Feb 10, 2025

@antonmedv, could you please explain why you didn't like this?

@antonmedv
Copy link
Member

Sorry , it was closed by accident. I was cleaning up PR. Please rebase the PR and I will review it.

@calebdw
Copy link
Author

calebdw commented Feb 10, 2025

@antonmedv, I've rebased 👍

@antonmedv
Copy link
Member

Hmm, please recreate PR. I can't reoopen in.
image

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

Successfully merging this pull request may close these issues.

2 participants