Here are the step by step instructions to set up Git deployment with GitLab using RunCloud:
- Create a project on GitLab. Give your project a name, choose the visibility level, and decide if you want to create a README file or not.
- After you have created the project, clone it to your local machine. You can use the command
git clone
followed by the URL of your project. You can find the clone URL in GitLab dashboard.
- You can clone your application using either HTTPS or SSH – just paste the appropriate URL in the command above.
For example,git clone https://gitlab.com/tatticoder/my-runcloud-site.git
.
- Open this cloned application in your favourite IDE such as VS Code or Jetbrains and make the required changes to your project files. For example, you can create an index file with some HTML code.
- Save and commit your changes using
git add .
andgit commit -m "message"
. Then push your changes to GitLab usinggit push origin main
. - After this, we will create a new web application on RunCloud. Go to the Web Application tab and click on Create Web Application. Choose Git Repository as the source and select GitLab as the provider.
- Give your web application a name and select a user account on your server. You can also create a new user account for each web application for better security.
- Specify the domain name and SSL settings for your web application. You can use either a custom domain name or a subdomain provided by RunCloud. You can also enable SSL using Let’s Encrypt or a custom certificate.
- In the Git section, provide the GitLab username and repository name for your project. In the given example, the repository name is
tatticoder/my-runcloud-site
. You can also specify the branch name, which ismain
by default.
- Next, create a deployment key for your web application. If this is your first time using GitLab with RunCloud, you’ll need to generate a deployment key. Click on the Generate button next to it and wait a few seconds.
- Now go to your GitLab dashboard and navigate to Settings > Repository > Deploy Keys for your project. Click on Add Key, paste the key, and give it a title. This will allow RunCloud to access your GitLab repository.
- Go back to the RunCloud dashboard and click on Deploy Web Application. This will pull the latest changes from your GitLab repository and deploy them to your server.
- You can check the status of the deployment in the Deployment tab. Once the deployment is successful, you can access your web application from the URL that you specified earlier.
- After setting up the Git application, you’ll need to set up a web hooks URL to make sure that RunCloud is notified when you create a new version of your web application.
- Go to the Git tab of your web application in the RunCloud dashboard and copy the provided URL.
- Next, go to your GitLabs dashboard and navigate to Settings > Webhooks. On this page, create a new webhook and paste the provided URL. Make sure to select the “Push events” trigger so that RunCloud is notified about push events.
- Finally, go back to your IDE and make a small change to your website. Commit your changes, and push them. This will trigger a new Deployment in the RunCloud dashboard and you will be able to see your changes on the live site within a couple of minutes.