๐Ÿ“—
smiley book
  • Smiley Books
  • AI
    • Readme
    • openai-whisper
      • ์ƒ˜ํ”Œ ์‹คํ–‰ํ•ด๋ณด๊ธฐ
      • GPU ์„œ๋ฒ„ ์ค€๋น„ํ•˜๊ธฐ
      • API๋กœ whisper๋ฅผ ์™ธ๋ถ€์— ์˜คํ”ˆํ•˜๊ธฐ
      • ํ”„๋กฌํ”„ํŠธ ์ง€์›
      • ์‹ค์‹œ๊ฐ„ message chat
      • ํ™”๋ฉด ์ด์˜๊ฒŒ ๋งŒ๋“ค๊ธฐ์™€ ๋กœ๊ทธ์ธ
      • ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ
      • ์‹ค์‹œ๊ฐ„ voice chat
      • fine tunning(๋ฏธ์„ธ ์กฐ์ •) ์œผ๋กœ ์„ฑ๋Šฅ ์˜ฌ๋ฆฌ๊ธฐ
      • app์—์„œ api๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ…์ŠคํŠธ๋กœ ๋ฐ”๊ฟ”๋ณด๊ธฐ
    • ollama - llm์„ ์‰ฝ๊ฒŒ ๋‚ด์ปด์—์„œ ์‹คํ–‰
      • ollama webui
      • ollama docker
    • stable diffusion
      • SDXL - text to image
      • SD-webui
    • ChatGPT
      • ๋‹ต๋ณ€์ด ๋Š๊ธธ๋•Œ
      • ์—ญํ• ์„ ์ •ํ•˜์ž
      • ๊ตฌ์ฒด์ ์ธ ์งˆ๋ฌธ
      • ๊ฒฐ๊ณผํ˜•ํƒœ๋ฅผ ์ง€์ •
      • ํ”„๋กฌํ”„ํŠธ๋ฅผ ์—ฌ๋Ÿฌ์ค„๋กœ ์‚ฌ์šฉํ•˜์ž.
      • ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ ๊ธ€ ๋ฒˆ์—ญ๋ณธ
    • Prompt Engineering
    • Auto-GPT
    • Gemini
      • google ai studio
      • gemini-api
      • embedding guide
    • Huggingface
      • huggingface ์‚ฌ์šฉ๋ฒ•
      • huggingface nlp ๊ณต๋ถ€์ค‘
    • kaggle
      • download dataset
    • langchain
      • langchain์„ ๊ณต๋ถ€ํ•˜๋ฉฐ ์ •๋ฆฌ
      • basic
      • slackbot
      • rag
      • document-loader
      • website-loader
      • confluence
      • memory
      • function-call
      • langsmith
      • agent-toolkit
  • Ansible
    • templates vs files and jinja2
    • dynamic inventory
    • limit ์˜ต์…˜ ๊ฐ•์ œํ•˜๊ธฐ
    • limit ์‚ฌ์šฉํ›„ gather_fact ๋ฌธ์ œ
  • AWS
    • AWS CLI
    • EKS
      • cluster manage
      • ALB Controller
      • external-dns
      • fargate
    • ECR
    • S3
    • Certificate Manager
  • Azure
    • Azure AD OAuth Client Flow
  • Container
    • Registry
    • ๋นŒ๋“œ์‹œ์— env๊ฐ’ ์„ค์ •ํ•˜๊ธฐ
  • DB
    • PXC
      • Operator
      • PMM
      • ์‚ญ์ œ
      • GTID
      • Cross Site Replication
    • Mssql
    • Mysql
  • dotnet
    • Thread Pool
    • Connection Pool
    • Thread Pool2
  • Devops
    • Recommendation
  • GIT
    • Basic
    • Submodule
  • GitHub
    • Repository
    • GitHub Action
    • GitHub PR
    • Self Hosted Runner
    • GitHub Webhook
  • GitLab
    • CI/CD
    • CI/CD Advance
    • Ssl renew
    • CI/CD Pass env to other job
  • Go Lang
    • ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•
    • multi os binary build
    • kubectl๊ฐ™์€ cli๋งŒ๋“ค๊ธฐ
    • azure ad cli
    • embed static file
    • go study
      • pointer
      • module and package
      • string
      • struct
      • goroutine
  • Kubernetes
    • Kubernetes๋Š” ๋ฌด์—‡์ธ๊ฐ€
    • Tools
    • Install with kubespray
    • Kubernetes hardening guidance
    • 11 ways not to get hacked
    • ArgoCD
      • Install
      • CLI
      • Repository
      • Apps
      • AWS ALB ์‚ฌ์šฉ
      • Notification slack
      • Backup / DR
      • Ingress
      • 2021-11-16 Github error
      • Server Config
      • auth0 ์ธ์ฆ ์ถ”๊ฐ€(oauth,OIDC)
    • Extension
      • Longhorn pvc
      • External dns
      • Ingress nginx
      • Cert Manager
      • Kube prometheus
    • Helm
      • Subchart
      • Tip
    • Loki
    • Persistent Volume
    • TIP
      • Job
      • Pod
      • Log
  • KAFKA
    • raft
  • KVM
    • kvm cpu model
  • Linux
    • DNS Bind9
      • Cert-Manager
      • Certbot
      • Dynamic Update
      • Log
    • Export and variable
    • Grep ์‚ฌ์šฉ๋ฒ•
  • Modeling
    • C4 model introduce
    • Mermaid
    • reference
  • Monitoring
    • Readme
    • 0. What is Monitoring
    • 1. install prometheus and grafana
    • 2. grafana provisioning
    • 3. grafana dashboard
    • 4. grafana portable dashboard
    • 5. prometheus ui
    • 6. prometheus oauth2
    • Prometheus
      • Metric type
      • basic
      • rate vs irate
      • k8s-prometheus
    • Grafana
      • Expolorer
    • Node Exporter
      • advance
      • textfile collector
  • Motivation
    • 3 Simple Rule
  • OPENNEBULA
    • Install(ansible)
    • Install
    • Tip
    • Windows vm
  • Reading
    • comfort zone
    • ๋ฐฐ๋ ค
    • elon musk 6 rule for insane productivity
    • Feynman Technique
    • how to interview - elon musk
    • ๊ฒฝ์ฒญ
    • Readme
  • Redis
    • Install
    • Master-slave Architecture
    • Sentinel
    • Redis Cluster
    • Client programming c#
  • SEO
    • Readme
  • Security
    • criminalip.io
      • criminalip.io
  • Stock
    • robinhood-python
  • Terraform
    • moved block
    • output
  • vault
    • Readme
  • VS Code
    • dev container
    • dev container on remote server
  • Old fashione trend
    • curity
    • MAAS
      • Install maas
      • Manage maas
      • Tip
Powered by GitBook
On this page
  • stages ์ƒ์„ฑ
  • ํŒŒ์ดํ”„๋ผ์ธ์—์„œ ์‚ฌ์šฉํ•  ๋ณ€์ˆ˜ ์„ ์–ธ
  • job ์ƒ์„ฑ
  • docker build
  • change log
  • release
  • staging ๋ฐฐํฌ
  • production ๋ฐฐํฌ(job template)
  • Approval
  • ์ „์ฒด ci/cd ํ”„๋กœ์„ธ์Šค
  • jira ticket create for rtp with release.md
  • when we click argocd sync button
  • deploy
  • rollback
  • todo

Was this helpful?

  1. GitLab

CI/CD

ํ”„๋กœ์ ํŠธ ์ตœ์ƒ์œ„์— .gitlab-ci.yaml ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ , ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ •ํ•œ๋‹ค.

stages ์ƒ์„ฑ

์‚ฌ์šฉํ•  ์Šคํ…Œ์ด์ง€๋ฅผ ์ „๋ถ€ ๋งŒ๋“ค์–ด์ค€๋‹ค.

stages:
  - build
  - testing
  - dev
  - release
  - qa
  - prod

ํŒŒ์ดํ”„๋ผ์ธ์—์„œ ์‚ฌ์šฉํ•  ๋ณ€์ˆ˜ ์„ ์–ธ

variables:
  IMAGE_NAME: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
  LATEST_IMAGE_NAME: ${CI_REGISTRY_IMAGE}:latest

job ์ƒ์„ฑ

run_job:
  stage: dev
  image: alpine:3.8
  before_script:
    - echo pre
  script:
    - echo hello world
  after_script:
    - echo post
unit_test_job:
  stage: dev
  image: alpine:3.8
  script:
    - echo unit test

run_job์„ ํ…Œ์ŠคํŠธ๋กœ ์ƒ์„ฑํ–‡๊ณ  unit_test_job๋„ ์ƒ์„ฑํ•ด๋ณด์•˜๋‹ค.

๋‘˜๋‹ค stage๊ฐ€ dev์ธ๊ฒƒ์„ ํ™•์ธํ• ์ˆ˜ ์žˆ๋‹ค.

run_e2e_tests:
  stage: testing
  image: alpine:3.8
  before_script:
    - echo pre
  script:
    - echo hello world
  after_script:
    - echo post

testing stage ์— job์„ ํ•˜๋‚˜ ์ถ”๊ฐ€ํ–‡๋‹ค.

docker build

echo "hello world" > index.html
vi Dockerfile
FROM nginx:1.20-alpine
COPY index.html /usr/share/nginx/html/index.html
EXPOSE 80
CMD ["/bin/sh", "-c", "exec nginx -g 'daemon off;';"]
WORKDIR /usr/share/nginx/html

.gitlab-ci.yaml ์— ์ถ”๊ฐ€ํ•˜์ž.

build stage ์— job์„ ํ•˜๋‚˜ ์ถ”๊ฐ€ํ–‡๋‹ค.

build:
  stage: build
  image: docker:20.10
  services:
    - docker:20.10-dind
  before_script:
    - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
  script:
    - docker build -f Dockerfile -t ${IMAGE_NAME} -t ${LATEST_IMAGE_NAME} .
    - docker push ${IMAGE_NAME}
    - docker push ${LATEST_IMAGE_NAME}
  after_script:
    - docker logout

${xxx}๋Š” variable์— ์žˆ๋Š” ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

CI_REGISTRY_USER, CI_REGISTRY_PASSWORD, CI_REGISTRY ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

๊ทธ๋ฆผ์ฒ˜๋Ÿผ ์ƒ์„ฑํ•ด์„œ ๋„ฃ์–ด์ค˜์•ผํ•œ๋‹ค.

ํ˜น์‹œ ์—ฌ๋Ÿฌ์‚ฌ๋žŒ์ด ๊ณต์œ ํ•˜๋ฉด ๊ทธ๋ฃน ๋‹จ์œ„๋กœ ์ ์šฉํ•˜๋Š”๊ฒŒ ํ‚ค๋ฅผ ๋ณดํ˜ธํ•˜๋Š”๋ฐ ๋„์›€์ด ๋ ๋“ฏ ์‹ถ๋‹ค.

change log

  • $CI_COMMIT_TAG => ํƒœ๊ทธ๋ฅผ ๋ถ™์ด๋Š” ์ˆœ๊ฐ„๋งŒ ๋™์ž‘์„ ํ•œ๋‹ค.

changelog:
  stage: release
  image: docker:git
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:'At %ci, %cN committed %h - %s' --decorate --graph >release.md
  artifacts:
    paths: [release.md]

git log๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐ”๋กœ ์ง์ „ ํƒœ๊ทธ ์ดํ›„๋กœ๋ถ€ํ„ฐ ์ง€๊ธˆ๊นŒ์ง€ git log๋ฅผ ๊ฐ€์ ธ์˜ค๊ณ , release.md๋กœ ์ €์žฅํ•œ๋‹ค.

release.md๊ฐ€ artifactory๋กœ ์ƒ์„ฑ์ด ๋˜์„œ ui์—์„œ ๋‹ค์šด๋ฐ›์„์ˆ˜ ์žˆ๋‹ค.

release

  • $CI_COMMIT_TAG => ํƒœ๊ทธ๋ฅผ ๋ถ™์ด๋Š” ์ˆœ๊ฐ„๋งŒ ๋™์ž‘์„ ํ•œ๋‹ค.

๋ฐ”๋กœ ์ง์ „์— ์ƒ๊ธด artifact๊ฐ€ ์ž๋™์œผ๋กœ ๋‹ค์šด์ด ๋œ๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ catํ•ด์„œ ๋ฆด๋ฆฌ์ฆˆ์— ๋„ฃ์œผ๋ฉด ๋œ๋‹ค.

needs๋ฅผ ์ด์šฉํ•˜๋ฉด ๋””ํŽœ๋˜์‹œ๊ฐ€ ๊ฑธ๋ฆฐ ์ž‘์—…์ด ๋จผ์ € ๋๋‚œํ›„ ์ด ์žก์„ ์‹คํ–‰ํ•œ๋‹ค. changelog๊ฐ€ ๋๋‚˜๋ฉด release๊ฐ€ ๋œ๋‹ค.

release:
  stage: release
  needs: ['changelog']
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - echo "running release_job for $TAG"
  release:
    tag_name: '$CI_COMMIT_TAG'
    name: 'Release $CI_COMMIT_TAG'
    description: '$(cat release.md)'

์ด์ œ ํƒœ๊ทธ๋ฅผ ๋ถ™์ด๊ณ  push๋ฅผ ํ•˜๋ฉด ๋ฆด๋ฆฌ์ฆˆ ํŽ˜์ด์ง€๊ฐ€ ๋œ๋‹ค.

staging ๋ฐฐํฌ

stage๋ฅผ staging์œผ๋กœ ๊ตฌ์„ฑํ–‡์Œ.

argocd repo๋ฅผ ์—…๋ฐ์ดํŠธ ํ•˜๋Š”๊ฒƒ์œผ๋กœ ๋ฐฐํฌ๊ฐ€ ๋งˆ๋ฌด๋ฆฌ ๋œ๋‹ค. ๊นƒ์„ ํด๋ก ํ•ด์„œ ๋‹ค์šด๋กœ๋“œํ•œํ›„ docker image tag๋งŒ ๋ฐ”๊ฟ”์ฃผ๊ณ  ๋‹ค์‹œ ์ปค๋ฐ‹ํ•˜๋ฉด๋œ๋‹ค.

staging-deploy:
  stage: staging
  image: alpine:3.8
  rules:
    - if: $CI_COMMIT_TAG
  before_script:
    - apk add --no-cache git curl bash
    - git config --global user.email "gitlab@gitlab.com"
    - git config --global user.name "GitLab CI/CD"
  script:
    - git clone https://${CI_USER}:${CI_PUSH_TOKEN}@gitlab.com/teamsmiley/staging.git
    - cd k8s-c1/apps/default/sample-www-internal
    - sed "s/:latest/:${CI_COMMIT_SHORT_SHA}/g" deploy.origin > deploy.yaml
    - git commit -am "change docker tag"
    - git push

deploy.origin ํŒŒ์ผ

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: www
  labels:
    app: www
spec:
  replicas: 1
  revisionHistoryLimit: 1
  selector:
    matchLabels:
      app: www
  template:
    metadata:
      labels:
        app: www
    spec:
      containers:
        - name: www
          image: registry.gitlab.com/teamsmiley/sample:latest
          ports:
            - containerPort: 80
              name: http
      imagePullSecrets:
        - name: gitlab-regcred

production ๋ฐฐํฌ(job template)

์Šคํ…Œ์ด์ง• ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•ด์„œ ๋งŒ๋“ค๋ฉด ๋œ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์ฝ”๋“œ์˜ ์ค‘๋ณต์ด ์ƒ๊ธด๋‹ค.

์—ฌ๊ธฐ์„œ job template๋ผ๋Š” ๊ฐœ๋…์ด ์ƒ๊ธด๋‹ค.

job template๋Š” ์‚ฌ์šฉํ•œ๊ณณ๋ณด๋‹ค๋Š” yamlํŒŒ์ผ์— ์ƒ๋‹จ์— ์œ„์น˜ํ•ด์•ผํ•œ๋‹ค. yaml์— ์ถ”๊ฐ€ํ•˜์ž.

jobname์ด .์œผ๋กœ ์‹œ์ž‘ํ•œ๋‹ค. ์ด๊ฑด ์‹ค์ œ๋กœ ๋™์ž‘ํ•˜์ง€๋Š” ์•Š๋Š” ์ž‘์—…์ด๋‹ค.

.deploy-template: &template
  rules:
    - if: $CI_COMMIT_TAG
  before_script:
    - apk add --no-cache git curl bash
    - echo ${CI_COMMIT_SHORT_SHA}
    - git config --global user.email "gitlab@gitlab.com"
    - git config --global user.name "GitLab CI/CD"
  script:
    - git clone https://${CI_USER}:${CI_PUSH_TOKEN}@gitlab.com/teamsmiley/staging.git
    - cd staging/apps/default/sample-www-internal
    - sed "s/:latest/:${CI_COMMIT_SHORT_SHA}/g" deploy.origin > deploy.yaml
    - git commit -am "change docker tag"
    - git push

yaml์— anchor๊ธฐ๋Šฅ์„ ์ด์šฉํ•œ๋‹ค.

&template ์ฒ˜๋Ÿผ &ํ•˜๊ณ  ์ด๋ฆ„์„ ์ ๋Š”๋‹ค.

์ด์ œ ์‚ฌ์šฉํ•  ๊ณณ์—์„œ ์ด๋ฆ„์„ ์ ์–ด์„œ ์‚ฌ์šฉํ•œ๋‹ค. <<: * ๋‹ค์Œ์— ์ด๋ฆ„์„ ์จ์„œ ์‚ฌ์šฉํ•œ๋‹ค.

staging-deploy:
  stage: staging
  image: alpine:3.8
  rules:
    - if: $CI_COMMIT_TAG
  <<: *template

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์œ„ ๋‚ด์šฉ์„ ๊ฐ€์ ธ๋‹ค๊ฐ€ ๋ถ™์—ฌ์ค€๋‹ค. ์ฝ”๋“œ ์ค‘๋ณต์„ ์ค„์ผ์ˆ˜ ์žˆ๋‹ค.

production๊ณผ staging์„ ํ•˜๋‹ค๋ณด๋‹ˆ git repo์˜ ๊ฒฝ๋กœ๊ฐ€ ๋‹ค๋ฅด๋‹ค.

staging.git / production.git ์ด๋‹ค. ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•ด์•ผํ• ๊นŒ?

- git clone https://${CI_USER}:${CI_PUSH_TOKEN}@gitlab.com/teamsmiley/staging.git
- cd staging/apps/default/sample-www-internal

์ด๋ถ€๋ถ„์ด ๋ฌธ์ œ์ธ๋ฐ ์ด๊ฑด ๊ฐ„๋‹จํ•˜๊ฒŒ variable์„ ์‚ฌ์šฉํ•˜๋ฉด๋œ๋‹ค.

.deploy-template: &template
  rules:
    - if: $CI_COMMIT_TAG
  before_script:
    - apk add --no-cache git curl bash
    - echo ${CI_COMMIT_SHORT_SHA}
    - git config --global user.email "gitlab@gitlab.com"
    - git config --global user.name "GitLab CI/CD"
  script:
    - git clone https://${CI_USER}:${CI_PUSH_TOKEN}@gitlab.com/teamsmiley/$gitrepo_name.git # $gitrepo_name์€ variable์„ ์‚ฌ์šฉํ•˜์—ฌ ์ •ํ•ด์ค€๋‹ค.
    - cd $gitrepo_name/apps/default/sample-www-internal # $gitrepo_name์€ variable์„ ์‚ฌ์šฉํ•˜์—ฌ ์ •ํ•ด์ค€๋‹ค.
    - sed "s/:latest/:${CI_COMMIT_SHORT_SHA}/g" deploy.origin > deploy.yaml
    - git commit -am "change docker tag"
    - git push
staging-deploy:
  stage: staging
  image: alpine:3.8
  rules:
    - if: $CI_COMMIT_TAG
  # ์ด๋ถ€๋ถ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค.
  variables:
    gitrepo_name: staging
  <<: *template

production-deploy:
  stage: production
  image: alpine:3.8
  rules:
    - if: $CI_COMMIT_TAG
  # ์ด๋ถ€๋ถ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค.
  variables:
    gitrepo_name: production
  <<: *template

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด variable์„ ์‚ฌ์šฉํ•˜์—ฌ staging์€ staging.git / production์€ production.git ์ด๋ ‡๊ฒŒ ์ •ํ•ด์ค€๋‹ค.

์ฝ”๋“œ์˜ ์ค‘๋ณต์„ ์ „๋ถ€ job template๋ฅผ ์ด์šฉํ•˜์—ฌ ์ฒ˜๋ฆฌํ• ์ˆ˜ ์žˆ๋‹ค.

Approval

environment์—์„œ approval์„ ์‚ฌ์šฉํ•˜๋ฉด ๋œ๋‹ค.

production-deploy:
  stage: production
  image: alpine:3.8
  # ์ด๋ถ€๋ถ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค.
  environment:
    name: prod
    url: https://www.aaa.com
  rules:
    - if: $CI_COMMIT_TAG
  variables:
    gitrepo_name: production
  <<: *template

ci/cd๋ฅผ ์‹คํ–‰ํ•˜๋ฉด environment๊ฐ€ ์ƒ์„ฑ๋œ๋‹ค.

setting >> ci/cd >> protect an environment

์ด์ œ cicd๋ฅผ ์‹คํ–‰ํ•ด๋ณด๋ฉด ํ”„๋กœ๋•์…˜์—์„œ ๋ฉˆ์ถฐ์žˆ๋Š”๊ฒƒ์„ ์•Œ์ˆ˜ ์žˆ๋‹ค.

environment ์— ๊ฐ€์„œ productin์„ ์„ ํƒํ•˜๊ณ  ๋“ค์–ด๊ฐ€๋ฉด ์ปจํŽŒ์„ ํ• ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

approval์„ ํ• ์ˆ˜๊ฐ€ ์žˆ๋‹ค.

approval์„ ํ•˜๋ฉด ๋‹ค์Œ ํ”„๋กœ์„ธ์Šค๊ฐ€ ์ง„ํ–‰๋˜๋Š”๊ฒƒ์„ ์•Œ์ˆ˜ ์žˆ๋‹ค.

์ „์ฒด ci/cd ํ”„๋กœ์„ธ์Šค

stages:
  - build
  - testing
  - dev
  - release
  - qa
  - prod

variables:
  IMAGE_NAME: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}
  LATEST_IMAGE_NAME: ${CI_REGISTRY_IMAGE}:latest

run_job:
  stage: dev
  image: alpine:3.8
  before_script:
    - echo pre
  script:
    - echo hello world
  after_script:
    - echo post
unit_test_job:
  stage: dev
  image: alpine:3.8
  script:
    - echo unit test

run_e2e_tests:
  stage: testing
  image: alpine:3.8
  before_script:
    - echo pre
  script:
    - echo hello world
  after_script:
    - echo post

build:
  stage: build
  image: docker:20.10
  services:
    - docker:20.10-dind
  before_script:
    - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
  script:
    - docker build -f Dockerfile -t ${IMAGE_NAME} -t ${LATEST_IMAGE_NAME} .
    - docker push ${IMAGE_NAME}
    - docker push ${LATEST_IMAGE_NAME}
  after_script:
    - docker logout

changelog:
  stage: release
  image: docker:git
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:'At %ci, %cN committed %h - %s' --decorate --graph >release.md
  artifacts:
    paths: [release.md]

release:
  stage: release
  needs: ['changelog']
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  rules:
    - if: $CI_COMMIT_TAG
  script:
    - echo "running release_job for $TAG"
  release:
    tag_name: '$CI_COMMIT_TAG'
    name: 'Release $CI_COMMIT_TAG'
    description: '$(cat release.md)'

.deploy-template: &template
  image: alpine:3.8
  rules:
    - if: $CI_COMMIT_TAG
  before_script:
    - apk add --no-cache git curl bash
    - echo ${CI_COMMIT_SHORT_SHA}
    - git config --global user.email "gitlab@gitlab.com"
    - git config --global user.name "GitLab CI/CD"
  script:
    - git clone https://${CI_USER}:${CI_PUSH_TOKEN}@gitlab.com/teamsmiley/staging.git
    - cd staging/apps/default/sample-www-internal
    - sed "s/:latest/:${CI_COMMIT_SHORT_SHA}/g" deploy.origin > deploy.yaml
    - git commit -am "change docker tag"
    - git push

staging-deploy:
  stage: staging
  # ์ด๋ถ€๋ถ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค.
  variables:
    gitrepo_name: staging
  <<: *template

production-deploy:
  stage: production
  # ์ด๋ถ€๋ถ„์„ ์ถ”๊ฐ€ํ•œ๋‹ค.
  variables:
    gitrepo_name: production
  <<: *template

jira ticket create for rtp with release.md

unit_test_job:
  stage: qa
  image: alpine:3.8
  script:
    - curl xxxxxxxxxx (jira api with api key)

this will create ma ticket

when we click argocd sync button

deploy

  • update jira ticket status to start

  • deploy

  • update jira ticket status to done

rollback

  • update jira ticket status to rollback-start

  • deploy

  • update jira ticket status to rollback-done

todo

  • approval email

PreviousGitHub WebhookNextCI/CD Advance

Last updated 1 year ago

Was this helpful?