Commit 48b0d45a authored by Simon Cornet's avatar Simon Cornet
Browse files

[ci] feat: add deployment step

parent 2a429a70
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -5,7 +5,8 @@ stages:

  # stages
  - "linting"
  - "build"
  - "image-build"
  - "deployment"


# include jobs
@@ -13,4 +14,5 @@ include:

  # deployment
  - local: ".gitlab/linting.yaml"
  - local: ".gitlab/build.yaml"
  - local: ".gitlab/image-build.yaml"
  - local: ".gitlab/deployment.yaml"
+37 −0
Original line number Diff line number Diff line
---

# deploy container on kubernetes
deployment:
  stage: "deployment"
  image:
    name: "cr.simoncor.net/siempie/ansible-deployment:latest"
    entrypoint: ["/bin/sh", "-c"]
  rules:

    # run only on push to default branch
    - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
    - when: "never"

  # prepare ssh
  before_script:

    # prepare ssh
    - |
        # prepare ssh
        mkdir -p ~/.ssh
        chmod 700 ~/.ssh
        echo "$SSH_CONFIG" > ~/.ssh/config
        echo "$SSH_DEPLOYMENT_KEY" > ~/.ssh/id_ed25519
        chmod 600 ~/.ssh/id_ed25519

  # deployment commands
  script:

    - |
        # initial kubernetes deployment
        ssh "$SSH_DEPLOYMENT_USER@mgmt01.infra.vpn.mirahsimon.us" "sudo -u simon \
        kubectl apply -f /home/simon/Documents/kaas-start-simoncor-net/manifests"

        # rollout deployment
        ssh "$SSH_DEPLOYMENT_USER@mgmt01.infra.vpn.mirahsimon.us" "sudo -u simon \
        kubectl rollout restart --namespace=start-simoncor-net deployment start-simoncor-net"
+2 −2
Original line number Diff line number Diff line
@@ -8,8 +8,8 @@ variables:
stages:
  - "build"

build image:
  stage: "build"
image-build:
  stage: "image-build"
  image: "docker:27.3.1"
  services:
    - name: "docker:27.3.1-dind"