Composer Updates with Source Operations

Composer Updates with Source Operations

Try Platform.sh: https://accounts.platform.sh/checkout/

An application on Platform.sh can define a number of operations that can be applied to its source code.

Source Operations can be fully automated, which can be useful when projects need scheduled updates applied to their applications.

These commands, once defined, can replace the need to push updates from a local repository by running composer update automatically.

In a.platform.app.yaml file, the source operation update is defined to do exactly this. It includes the update command, as well as the two commands to add and commit those updates to the repository. Adding this feature is as simple as including these lines and pushing to a branch on Platform.sh

Once the source operation has been defined, you can trigger the update to take place using the CLI command platform source-operation:run update.

As a result, the operation will execute, push the commit, and trigger the normal build process on that environment.

Once you are satisfied with your update command, it can be modified to run automatically. Simply add an API Token to the project and install the CLI during the build hook.

Then define a cron job to run the source operation as often as you would like it to check for updates. It is even possible to read from the PLATFORM_BRANCH environment variable to restrict the operation only to certain environments, such as the dedicated update-dependencies environment shown here. Running this operation is that environments sole purpose, and prior to running it syncs all code and data from master.

Merge the newly defined source operation into master, and then create the update-dependencies environment that operation is looking to run on. That way, your project will rebuild with updated dependencies each day when they are available.

Test the updates, and then merge into master as a part of the application's daily maintenance routine.