Routes.yaml included in continuous deployments

I am currently using the official github integration to deploy a ghost theme every time there is an update in the repository. However, it doesn’t seem that the github action / ghost api provide a way to update routes.yml in case of routing changes.

Does this functionality exist in the ghost api? If not, is it planned? Currently, it creates a manual step in deployment.

Thanks for your help!

1 Like

From reading the source code of the Github Action that deploys the theme, it explicitly mentions including routes.yaml in the zip bundle.

It seems it should appear at content/settings/routes.yaml in your theme to land in the right place on the server, but this is not tested.

If this is correct, it could stand to be better documented.

For example, it should be mentioned in the example Theme structure here:

@Cathy_Sarisky Can you confirm that routes.yaml can appear in a theme like that?

That line of code excludes everything after it from being uploaded to Ghost (when a Zip file isn’t provided). This helps keep theme sizes small (no 20GB node_modules :rofl:) and deployment quicker because none of those files (including routes.yaml) have any affect when part of an active theme.

Thanks for the correction @RyanF. I missed the -x for “exclude” and that makes all the difference!

Perhaps the CI pipeline should support optionally support updating the routes.yaml. I see that the Admin API doesn’t support this, and maybe it shouldn’t.

If I wanted to do this, I might create my own Github Actions Workflow file that adds an extra step to scp the routes.yaml file to the right place on my server.

The advantage of this over manually updating routes.yaml is that the history of changes to the file are stored in git in case a serious mistake is made when updating it.

1 Like

I forgot to mention that routes.yaml is often included in theme files as an example of how to implement them.

It’s definitely possible to SCP the file directly onto the server, but it’ll require Ghost to be restarted for the changes to take effect.

1 Like