steps:
    - name: setup
      image: node:22-alpine
      commands:
          - apk update && apk add git
          - npm i typescript -g
          - npm install
          - echo '✅ success setup project'
      when:
          branch:
              - main

    - name: build-swagger
      image: node:22-alpine
      environment:
          NODE_ENV: prod
      commands:
          - npm run swagger
      when:
          branch:
              - main

    - name: build-src
      image: node:22-alpine
      environment:
          NODE_ENV: prod
      commands:
          - npm i typescript -g
          - npm run build:production
          - echo '✅ success compile typescript and ready to deploy'
      when:
          branch:
              - main

    - name: deploy
      image: docker
      commands:
          - docker builder prune -f
          - docker container prune -f
          - docker-compose build
          - docker-compose up -d --no-deps --build --remove-orphans
      volumes:
          - /var/run/docker.sock:/var/run/docker.sock
      when:
          branch:
              - main
