stages:
  - build
  - deploy

build-dev:
  stage: build
  when: on_success
  only:
    - main
  image: docker:stable
  services:
    - name: docker:dind
      command: ["--insecure-registry=103.82.242.92:8900"]
  script:
    - docker logout
    - docker login -u $DEPLOY_USERNAME -p $DEPLOY_TOKEN 103.82.242.92:8900
    - docker build -t 103.82.242.92:8900/medols/web-kebaikan-indonesia:dev .
    - docker push 103.82.242.92:8900/medols/web-kebaikan-indonesia:dev

auto-deploy:
  stage: deploy
  when: on_success
  only:
    - main
  image: curlimages/curl:latest
  services:
    - docker:dind
  script:
    - curl --user admin:$JENKINS_PWD http://38.47.180.165:8080/job/auto-deploy-kebaikan-indonesia/build?token=autodeploymedols
