What is the deploy feature ?

The deploy feature give you the opportunity to deploy a branch of your gitlab repository into your development.

Understanding the connection to .gitignore

The deployment function is directly linked to the .gitignore file, as the latter determines which files are taken into account by Git and therefore updated during deployment, and which persist locally without being overwritten;

How to deploy with the repository

Feature configuration

In the same tab, you can define the auto-deploy option. This give you the possibility to synchronize your development env. to your branch selected on the credentials tab. By default master is selected.

Auto Deploy Each time you push something in your branch currently selected you will have a deployment. This is also true if there is a Merge Request (MR) validation on the branch.

In the credentials tab you will find a drop down with the list of available branches in the reprository.

Source code You can update it whenever you want.

Steps to deploy

To deploy something you have to commit and push something…

Clone the project in your local machine

Below an example of the user interface. You can easily clone the project in your machine.

Gitlab ui

Use git to commit & push

Here a basic example of git commands, after some file updates.

# Add your updates in the index
git add .

# Comment your commit please :thank:
git commit -m "my usefull comment"

# Send your updates into your repository
git push origin my-branch

Deploy

In the same tab (DEPLOY) appear the new commits (never deployed).

commits_since_last_deploy

You must press the button DEPLOY NOW to deploy your new commits pushed on the branch. This will deploy it on the environment. This is not necessary if you enabled Automated deployment. 🚨

When you pressed “Deploy now” you will have the following steps:

deploy_latest_code

Take care, sometimes, updates have been done directly in the serveur (via SFTP, a module etc.)

In the deploy tab you will find a new window called “Unmerged changes detected“ in which you will find the details of updates (on a new branch hyperlane-my-branch-name )

unmerged_changes_detected

Two options, first don’t use it and erase updates with a new deploy (force), second click on “review and merge button” to get the detail and use gitlab link to go on the temporary branch created to compare with the last version. You can easily merge and deploy.

changed_files

Check the deploy worked properly

Now, you have to verify in the deployment in EVENTS tab and a new line should be here with Deploy latest code from Git with the name of the user which deployed it and the date when is happened. For example :

event_log


How the repository deploiement works

The deploy goes through a few steps to ensure that everything should work properly when it’s done like checking your PrestaShop configuration, installing vendors with composer and regenerate its autoloader and much more.

If the deploy is a success (not a failed deploy) no action required.


How to handle a failed deploy with the repository

How to know if deploy has failed ? Take a look at the EVENTS tab, you’ll see your last deploy action. If you have a pink flag FAILED on the right, then it has failed.

deploy_failed

At this moment, you don’t know why nor how to solve it and the impact on your infrastructure. The best action is to click on this event, it will show you the detail of the fail. For example :

output_error

Then you have to debug yourself the error…until the deployment is successful.

In some cases it’s due to composer.(json|lock) file(s) that couldn’t be executed or doesn’t have the right permissions.
If needed you can always ask some help to the PrestaShop Enterprise support 🙂