LAB 1 — GitLab CI + Pages From Scratch
Source: Dev.to
PART 1 — Register GitLab Account
-
Create a GitLab account
- Go to and click Register.
- Fill in Email, Username, and Password, then verify your email.
-
Create a new project
- After logging in, click New project → Create blank project.
- Project name:
gitlab-lab - Visibility: Public (easier for Pages)
- (Optional) Check Initialize repository with a README.
- Click Create project.
-
Add an SSH key
# Generate a new SSH key (replace with your email) ssh-keygen -t ed25519 -C "your_email" # Press Enter for all prompts cat ~/.ssh/id_ed25519.pub # copy the output- In GitLab: Top right → Profile → Preferences → SSH Keys → Add new key → paste the key → Add key.
- Test the connection:
ssh -T git@gitlab.com # Expected output: "Welcome to GitLab, @yourusername!" -
Clone the repository
- On the project page, go to Code → Clone → SSH and copy the URL (e.g.,
git@gitlab.com:username/gitlab-lab.git).
git clone git@gitlab.com:username/gitlab-lab.git cd gitlab-lab ls -la # you should see a .git folder - On the project page, go to Code → Clone → SSH and copy the URL (e.g.,
-
Create the site structure
mkdir public cat > public/index.html My First GitLab CI Site
Hello DevOps World 🚀
EOF
6. **Add a CI configuration**
```bash
touch .gitlab-ci.yml
nano .gitlab-ci.yml # paste the following
image: busybox
pages:
stage: deploy
script:
- echo "Deploying to GitLab Pages"
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- Save and exit the editor.
-
Commit and push
git add . git commit -m "Setup GitLab Pages site" git push origin master # use `main` if your default branch is named main -
Run the pipeline
- Navigate to Build → Pipelines in GitLab.
- The pipeline should start, then turn green once completed.
- Click the pipeline to view job logs – this is your first CI job.
-
View the deployed site
- After the pipeline succeeds, go to Deploy → Pages.
- Open the provided URL, e.g.,
https://username.gitlab.io/gitlab-lab/. - You should see Hello DevOps World 🚀.
What you’ve accomplished
- Registered on GitLab and created a project.
- Set up SSH authentication.
- Added a simple static site (
public/folder). - Configured a CI/CD pipeline with
.gitlab-ci.yml. - Deployed the site using GitLab Pages.
The pipeline runs automatically on pushes to the default branch, turning your repository into a fully automated deployment workflow.