Skip to content

GitHub Deployments Recipes

These recipes can be used with our advanced deployment mode. In this mode, you can provide a GitHub workflow script to process your repository files before deployment. This opens up many possibilities, such as checking your code to ensure it meets your team’s coding standards, running unit tests, excluding files in your repository from the deployment, installing dependencies, and much more. 

Note: these recipes include example workflow scripts. Be sure to check the repository structure as well as the scripts. If your repository structure differs, then you may need to update the paths in the workflow scripts. 

Installing Composer dependencies

If your project includes Composer and you don’t want to store the vendor folder in your repository, you can fetch your dependencies at deployment time instead. 

Links:

Installing Node dependencies 

If your project requires Node to bundle assets or scripts, and you don’t want to store the node_modules folder in your repository, you can fetch your dependencies and run commands at deploy time instead. 

Links:

Running code checks and unit tests and failing workflow if they don’t pass

You usually only want to deploy your code once you’re sure it’s working correctly. This example shows you how to run PHPCodeSniffer and PHPUnit before creating the deployment artifact. If any of these tasks fail, the code will not be deployed. 

Links:

Excluding repository files from the deployment

There is a chance you won’t need to deploy every file in your repository. To exclude specific files, you can tell the upload-artifact action which files to include and ignore when specifying the path value. For example, in the workflow file below, the current directory, ., is included, but any file path starting with !, e.g. !node_modules, is excluded. You can download the deployment artifact and compare it to the repository contents.

Links:

Using Git submodule dependencies in your project

Git allows you to nest Git repositories inside of your main repository. These are known as submodules, and this recipe shows how to use submodules in your workflow script. 

Links:

Last updated: March 14, 2024