# #Deployment via Git

* GitLab Deployment on Cloudways Platform
  * Step 1: Generate the SSH Key
  * Step 2: Upload SSH Key To GitLab Repository
  * Step 3: Copy the SSH Address of the Repository
  * Step 4: Deploy the Application Code from the Repository

### Deploy Using GitLab on Cloudways Platform

The process of deploying PHP apps on the Cloudways platform from GitLab is a simple matter of executing the following steps:

1. Generate SSH Key
2. Upload SSH to the GitHub Repository
3. Copy the SSH address of the repository
4. Deploy the application code from the repository

You can deploy PHP applications on the Cloudways Platform very easily, thanks to the integrated "**Deployment Via Git**" feature that helps connect your Git repository with the Cloudwyas managed server

{% tabs %}
{% tab title="Step 1" %}
**Step 1: Generate the SSH Key**

Sign in to your Cloudways account, visit the server where you wish to deploy the application, and head to the Application Settings.\ <br>

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2Fb3XwpugoOmbSX3f5VuFH%2Fimage.png?alt=media&#x26;token=242cfd1c-0c93-465a-a7d8-943ced756720" alt=""><figcaption><p>Pic 1. Generate the SSH Key</p></figcaption></figure>

In the Application Setting, head to the **Deployment Via Git** option available in the menu on the left of the window and click **Generate SSH Key**.

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2F5UqPdxmmV2L06otNS8u2%2Fimage.png?alt=media&#x26;token=ee2a3d68-8830-428a-968d-031b87fcb381" alt=""><figcaption><p>Pic 2. Generate the SSH Key</p></figcaption></figure>

This will automatically generate an SSH key. Click **View SSH Key** which can be copied by hovering over and clicking the key.

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2F3EEoXHxA50W2dJgSrwtj%2Fimage.png?alt=media&#x26;token=261d1d75-0ac8-4d0a-83c2-26c68984bbf2" alt=""><figcaption><p>Pic 3. Generate the SSH Key</p></figcaption></figure>

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2F6fIqp3KBvHSovA1Nhl4v%2Fimage.png?alt=media&#x26;token=a5de2d25-f771-42a0-ae12-7dd3b7ea5bca" alt=""><figcaption><p>Pic 4. Generate the SSH Key</p></figcaption></figure>
{% endtab %}

{% tab title="Step 2" %}
**Step 2: Upload SSH Key to GitLab Repository**

Move to the repository on GitLab and to the account's settings page.

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2FEgW4FSWCqq6bvMxPq2N7%2Fimage.png?alt=media&#x26;token=0390ad56-1252-44d7-9caf-7df3e09dbc7f" alt=""><figcaption><p>Pic 1. Upload SSH Key to GitLab Repository</p></figcaption></figure>

Move to the SSH Keys setting and add the SSH Key you have copied from Cloudways. Give a **title** to the SSH Key.&#x20;

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2FWsAZjiBrZoErFSruXUDu%2Fimage.png?alt=media&#x26;token=dcba1650-c135-4f36-8fa9-4a6fb31263cd" alt=""><figcaption><p>Pic 2. Upload SSH Key to GitLab Repository</p></figcaption></figure>
{% endtab %}

{% tab title="Step 3" %}
**Step 3: Copy the SSH Address of the Repository**

Move to the repository which you need to clone on the server. Click the Clone option which drops down and shows two options, Clone with SSH or Clone with HTTPS. Copy the URL under the **Clone with SSH** (notes: always remove the .git at the end of the SSH URL before adding to Cloudways).

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2F4qusuLU3rKQb686LqI6c%2Fimage.png?alt=media&#x26;token=c433d089-f3d2-4719-993b-1eae9432ad37" alt=""><figcaption><p>Pic 1. Copy the SSH Address of Repository</p></figcaption></figure>
{% endtab %}

{% tab title="Step 4" %}
**Step 4: Deploy the Application Code from the Repository**

* Move back to the Cloudways Application Settings > [Deployment Via Git](https://www.cloudways.com/blog/wordpress-github/) and paste the SSH address of the repository you have copied.&#x20;

  <figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2FLnZYZEEU6WkNBIQM9mQH%2Fimage.png?alt=media&#x26;token=ac8cae47-e3ea-434d-81e1-1b8e13da02fe" alt=""><figcaption><p>Pic 1. Deploy the Application Code from the Repository</p></figcaption></figure>

* Click Authenticate to let Cloudways authenticate the SSH address.&#x20;

  <figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2FVcyapdpm6O0pis3vuxDA%2Fimage.png?alt=media&#x26;token=dc1abd2c-788a-4562-80ee-0eba02c78eac" alt=""><figcaption><p>Pic 2. Deploy the Application Code from the Repository</p></figcaption></figure>

* After authentication, select the branch of your GitLab repository you need to deploy from. For this example, I am using Master Branch.

* Next, type the deployment path. Make sure to end the deployment path with a /. If you leave this field empty, the code will be deployed to the **public\_html/** folder by default.&#x20;

Finally, click **Start Deployment** to deploy your code.&#x20;

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2Fql2NVo6RQkt57W3gJCYE%2Fimage.png?alt=media&#x26;token=d087da79-23e9-4eb3-94f4-3d9a990b1c01" alt=""><figcaption><p>Pic 3. Deploy the Application Code from the Repository</p></figcaption></figure>

Upon successful GitLab deployment of your application, you'll get a green-colored pop-up message "**Git cloned**". &#x20;

<figure><img src="https://115803331-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F705N8OeBYBxKGzhvaDVF%2Fuploads%2FYZEz7U21MNZJxIKU7x0x%2Fimage.png?alt=media&#x26;token=c012f6cc-9e71-4c56-bf5d-f76f85182e57" alt=""><figcaption><p>Pic 4. Deploy the Application Code from the Repository</p></figcaption></figure>

Further, you can pull your code from your GitLab repository each time you make changes there with a simple **Pull** request.
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://madeindonesia.gitbook.io/mi-guide/project-deployment-v1.2.1/deployment-via-git.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
