(01)Add pipeline to repo
Linux
1git add .gitlab-ci.yml2git commit -m 'Add GitLab CI pipeline'3git pushBuild, test, and deploy with .gitlab-ci.yml — Docker-in-Docker included
.gitlab-ci.yml
1stages:2 - build3 - test4 - deploy5 6variables:7 DOCKER_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA8 9build:10 stage: build11 image: docker:2412 services:13 - docker:24-dind14 script:15 - docker build -t $DOCKER_IMAGE .16 - docker push $DOCKER_IMAGE17 only:18 - main19 20test:21 stage: test22 image: node:20-alpine23 script:24 - npm ci25 - npm test26 27deploy:28 stage: deploy29 image: bitnami/kubectl:latest30 script:31 - kubectl set image deployment/myapp app=$DOCKER_IMAGE32 environment:33 name: production34 only:35 - mainWhat to add before production merge
| Aspect | Minimal | Production |
|---|---|---|
| Auth | AWS_ACCESS_KEY_ID in CI variables | OIDC / workload identity — no static keys |
| Runners | shared runners, any tag | dedicated runners with pinned tags + isolation |
| Deploy | manual deploy on every commit | main protected; deploy stage manual or tagged release only |
| Scan | build only | container_scanning / Trivy gate before push |
| Secrets | KUBECONFIG file variable | short-lived cluster tokens; masked + protected vars |
| Branch protection | none | protected main + merge request pipelines required |
Step 01
1git add .gitlab-ci.yml2git commit -m 'Add GitLab CI pipeline'3git push