name: Deploy on package push

on:
  registry_package:
    types: [published, updated]
  workflow_dispatch:

jobs:
  deploy-marcopedone:
    runs-on: ubuntu-latest
    if: contains(github.event.registry_package.name, 'marcopedone')
    concurrency:
      group: deploy-marcopedone
      cancel-in-progress: true
    steps:
      - name: Wait for batch
        run: sleep 30

      - name: Deploy command
        run: |
          curl -X 'POST' \
           'https://dock.marcopedone.it/api/compose.deploy' \
           -H 'accept: application/json' \
           -H 'Content-Type: application/json' \
           -H 'x-api-key: gbiVIPaEQtkPywiAOIxiBtLrjKVuIqcnXXNMTzMXZoyTgJtgyLpHrlfBEqIcyEUM' \
           -d '{"composeId": "1Q1nPft6iaEDENfpYxq99"}'
  deploy-infoalloggi:
    runs-on: ubuntu-latest
    if: contains(github.event.registry_package.name, 'infoalloggi')
    concurrency:
      group: deploy-infoalloggi
      cancel-in-progress: true
    steps:
      - name: Wait for batch
        run: sleep 30

      - name: Deploy command
        run: |
          curl -X 'POST' \
           'https://dock.infoalloggi.it/api/compose.deploy' \
           -H 'accept: application/json' \
           -H 'Content-Type: application/json' \
           -H 'x-api-key: iIKlaMNilGkzCIgGNmQbzxUfvrwAwFEXcDBVxzVbSLPghbqLiagXcvwJRfLZxxao' \
           -d '{"composeId": "7apez8FViLShEjsFxlRNY"}'
