name: Deploy service message-delivery-method-web-push
run-name: ${{ github.actor }} deployed to build branch
on:
  push:
    branches:
      - main
    paths:
      - 'services/message-delivery-method-web-push/**'
      - 'packages/couchdb-changes-stream/**'
      - '.gitea/workflows/deploy-service-message-delivery-method-web-push.yaml'

jobs:
  service message-delivery-method-web-push:
    runs-on: ubuntu-latest

    container:
       volumes:
          - /www/hereconnect.condev.ru:/www/hereconnect.condev.ru

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '22'

      - name: install dependencies
        run: |
          corepack enable pnpm && corepack use pnpm@8.15.9
          pnpm install --filter ./services/message-delivery-method-web-push

      - name: build service
        run: |
          pnpm build -w services/message-delivery-method-web-push
          pnpm --filter ./services/message-delivery-method-web-push deploy --prod build/service-message-delivery-method-web-push

      - name: build docker image
        run: |
          docker build  --file services/message-delivery-method-web-push/Dockerfile -t hereconnect/service-message-delivery-method-web-push:${{env.GITHUB_SHA}} build/service-message-delivery-method-web-push
          docker tag hereconnect/service-message-delivery-method-web-push:${{env.GITHUB_SHA}} hereconnect/service-message-delivery-method-web-push:latest

      - name: cleanup build directories
        if: always()
        run: |
          docker rmi hereconnect/service-message-delivery-method-web-push:${{env.GITHUB_SHA}}