clone:
  git:
    image: woodpeckerci/plugin-git
    settings:
      partial: false
      depth: 15

steps:
  test:
    image: docker
    commands:
      - apk add curl
      - docker build .
    when:
      - event: push
        branch:
          exclude: ["main"]
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

  build:
    image: docker
    commands:
      - apk add curl
      - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD registry.yetaga.in
      - docker build -t registry.yetaga.in/bookstores:latest .
      - docker push registry.yetaga.in/bookstores:latest
      - 'curl http://100.113.98.36:4000/api/fetch -H "Authorization: Bearer $COMPOSE_TOKEN"'
      - 'curl http://100.113.98.36:4000/api/update -H "Authorization: Bearer $COMPOSE_TOKEN"'
    secrets: [docker_username, docker_password, compose_token]
    when:
      - event: push
        branch:
          include: ["main"]
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock