DAY 14-DEPLOYING VIA GIT
Hi all….yesterday I had posted on how to deploy directly through GitLab without using the Terminal or Git Bash……today I will tell you how to do the same via terminal.
1.First create a project via GitLab using the steps I mentioned yesterday.
- Next go to the local folder present in your computer which contains the files necessary for deploying (i.e) index.html and style.css. Open the folder right click and select Open with Terminal or Gitbash.
3.Go to your project in Gitlab and from the code tab copy the URL present under Clone with HTTPS. Go to the terminal and type in the following command
git clone (copied URL)
git add .
git commit -m "Some comment"
git push
Press Enter after typing each line of code. Once all your files are successfully pushed refresh your project page in Git and the files will be displayed.
4.Then click on + button in your project repository and click on create new file and type the name as .gitlab-ci.yml and enter the following code:
pages:
stage: deploy
script:
- mkdir public
- cp index.html public/
artifacts:
paths:
- public
only:
- main
It will suggest creating a template file but copy the above code only. Also if your images and css are in a separate file or folder you need to make them also public by adding the following code:
script:
- mkdir public
- cp index.html public/
- cp-r Folder(or)Filename/public
Once this file is created,GitLab will automatically start the deployment process.
5.Go to menu icon on the top left corner of your project and click on Deploy->Pages to check the status of your live site.
7.After few minutes your site will become live and the URL will be displayed in the Pages tab.
This is how we can create a live site using terminal….that’s all for today…see you all in the next post!