## List of stages for jobs, and their order of execution
## Create ssh_key on server with command: "ssh-keygen -t rsa -C "project@edutalk.edu.vn" -b 4096"
## Add content on "~/.ssh/id_rsa" to Variable $SSH_KEY on https://gitlab.com/edutalk-platform/client-backend/-/settings/ci_cd
## Add content on "cat "~/.ssh/id_rsa.pub" to " ~/.ssh/authorized_keys" on servers
#variables:
#  USERNAME: "root"
#  IP_BETA: "128.199.167.7"            # IP server
#  IP_STAGE: "103.253.147.140"         # IP server
#  IP_PRODUCTION: "103.130.212.165"       # IP server
#  FOLDER: "admin.edutalk.edu.vn/html" # folder project on server
#stages:
#  - build-beta
#  - build-staging
#  - build-production
#  - test
#  - deploy-beta
#  - deploy-staging
#  - deploy-production
#unit-test-job:   # This job runs in the test stage.
#  stage: test    # It only starts when the job in the build stage completes successfully.
#  script:
#    - echo "Running unit tests... This will take about 60 seconds."
#    - sleep 1
#    - echo "Code coverage is 90%"
#  only:
#    - staging
#    - master
#    - release
## test code
#lint-job:
#  stage: test
#  script:
#    - echo "Linting code... This will take about 10 seconds."
#    - sleep 1
#    - echo "No lint issues found."
#  only:
#    - staging
#    - master
#    - release
## build beta
#build-beta:
#  image: node:16-alpine3.14
#  stage: build-beta
#  only:
#    - master
#  script:
#    - yarn
#    - yarn beta-build
#  cache:
#    paths:
#      - node_modules/
#  artifacts:
#    paths:
#      # build folder
#      - dist/
#    expire_in: 1 hour
## production beta
#deploy-beta:
#  stage: deploy-beta
#  before_script:
#    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
#    - eval $(ssh-agent -s)
#    - ssh-add <(echo "$SSH_BETA_KEY")
#    - mkdir -p ~/.ssh
#    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
#  script:
#    - ls -la dist/
#    - ssh "$USERNAME"@"$IP_BETA" "rm -rf /var/www/$FOLDER/*"
#    - scp -r dist/* "$USERNAME"@"$IP_BETA":/var/www/$FOLDER/
#  only:
#    - master
#
## build stage
#build-stage:
#  image: node:16-alpine3.14
#  stage: build-staging
#  only:
#    - staging
#  script:
#    - yarn
#    - yarn stage-build
#  cache:
#    paths:
#      - node_modules/
#  artifacts:
#    paths:
#      # build folder
#      - dist/
#    expire_in: 1 hour
## production stage
#deploy-staging:
#  stage: deploy-staging
#  before_script:
#    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
#    - eval $(ssh-agent -s)
#    - ssh-add <(echo "$SSH_STAGE_KEY")
#    - mkdir -p ~/.ssh
#    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
#  script:
#    - ls -la dist/
#    - ssh "$USERNAME"@"$IP_STAGE" "rm -rf /var/www/$FOLDER/*"
#    - scp -r dist/* "$USERNAME"@"$IP_STAGE":/var/www/$FOLDER/
#  only:
#    - staging
#
## build production
#build-production:
#  image: node:16-alpine3.14
#  stage: build-production
#  only:
#    - release
#  script:
#    - yarn
#    - yarn build
#  cache:
#    paths:
#      - node_modules/
#  artifacts:
#    paths:
#      - dist/
#    expire_in: 1 hour
## production
#deploy-production:
#  stage: deploy-production
#  before_script:
#    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
#    - eval $(ssh-agent -s)
#    - ssh-add <(echo "$SSH_PRODUCTION_KEY")
#    - mkdir -p ~/.ssh
#    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
#  script:
#    - ls -la dist/
#    - ssh "$USERNAME"@"$IP_PRODUCTION" "rm -rf /var/www/$FOLDER/*"
#    - scp -r dist/* "$USERNAME"@"$IP_PRODUCTION":/var/www/$FOLDER/
#  only:
#    - release
