mehrancodes / laravel-harbor

a cli tool to Quickly create on-demand preview environment for your app on Laravel Forge.
https://www.laravel-harbor.com
MIT License
75 stars 7 forks source link

update git repo on PR update #34

Closed mgkimsal closed 11 months ago

mgkimsal commented 11 months ago

I've updated code in a PR and it triggers a new deploy/build, but the git repo is not updated

public function __invoke(ForgeService $service, Closure $next)
    {
        if (! $service->siteNewlyMade) {
            return $next($service);
        }

        $this->information('Installing the git repository.');

        $service->setSite(
            $service->site->installGitRepository([
                'provider' => $service->setting->gitProvider,
                'repository' => $service->setting->repository,
                'branch' => $service->setting->branch,
                'composer' => false,
            ])
        );

        return $next($service);
    }

I think there should be a $service->site->updateGitRepository(...) instead of the immediate return $next();

Agreed? Unsure if that's intended or not, but I'd need PRs to update with new code if the code was updated.

mgkimsal commented 11 months ago

potential fix in https://github.com/mehrancodes/veyoze/pull/35

mehrancodes commented 11 months ago

To trigger the site deploy on new PR commits, consider listening for the synchronize event in the GitHub Action. Also, by setting FORGE_QUICK_DEPLOY=true, Forge will auto-update the site. I'll share a manual trigger example shortly.

Update: Just to clarify, the updateGitRepository method only updates git parameters and doesn't deploy on new commits. If that's what you're looking for, we can certainly incorporate it.

mgkimsal commented 11 months ago

Not familiar with 'synchronize', but in general, I would expect if it deploys on a PR, changes to that PR (before it's closed) should also trigger updates/redeploy to get latest version.

i will check FORGE_QUICK_DEPLOY

mehrancodes commented 11 months ago

I finally got the chance to prepare the provision workflow with ability to re-deploy on new changes.

Here is the complete working workflow you can use https://github.com/mehrancodes/veyoze-laravel-sample/blob/main/.github/workflows/pr-preview-provision.yml

Also here is a PR showing how does the provisioning works: https://github.com/mehrancodes/veyoze-laravel-sample/pull/6

I hope it gives you a better view.

marking this issue as completed, but feel free to reach out again if any concern left.