Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kay899's avatar

How to schedule API calls for Forge deployment

Hi,

I would like to build an application, where a client can decide to "go live" himself. When clicking on a button I would like to start the four needed API calls for Forge:

  1. Create Site
  2. Install GIT Repository
  3. Change ENV file
  4. Deploy Application

I will do these calls with a Forge API SDK package. That is not my probem.

Actually I don't have a good idea how to schedulde these calls? I know that steps 1 and 2 can tale 30 seconds up to over 3 minutes till they are finished.

So for example step 1 gives me back the SiteID in Forge, but the status will be "installing". How can I make somekind of Job that checks if this status is not "installing" anymore and then starts the next API call for step 2?

Home someone could give a some hints how to deal with that?

Thanks

kay899

0 likes
3 replies
okawei's avatar

You could poll every x minutes to see if the site is created and repository is installed with: https://forge.laravel.com/api-documentation#list-sites

Checking the

            "repository_status": null,

field. Once it's created and repository is installed you can then update the env file and deploy the app. Might be a delay of up to a couple minutes but does that really matter for the deployment time?

Also I'd recommend having the polling method error out after an hour or so, just so you don't use up Forge's traffic ;)

kay899's avatar

How can I make a Job that checks every e.g. 3 minutes if the status has been changed?

Is there something like, if this is false, then retry this job in 3 minutes?

And if it then is true, Job is finished!

How can I make this behavior for a Job?

okawei's avatar

You could do that many different ways, store a field in the db, put a key in a never expiring cache, store it in a file, whatever you see as fit. Then in your kernel when you're defining the scheduling for your job just have a check before it's defined if the site has been created.

Please or to participate in this conversation.