name: Update website
on:
  pull_request:
    types: [closed]
concurrency:
  group: website-trigger-${{ github.ref }}
  cancel-in-progress: true
jobs:
  trigger:
    if: github.event.pull_request.merged == true &&
      github.event.pull_request.base.ref == 'master' &&
      github.repository == 'netdata/netdata'
    runs-on: ubuntu-latest
    steps:
      - name: Check Labels
        id: label-check
        run: |
          LABELS='${{ toJSON(github.event.pull_request.labels) }}'
          echo "Labels: $LABELS"
          if [[ "$LABELS" =~ "integrations-update" ]]; then
            echo "has_label=true" >> $GITHUB_OUTPUT
          fi
      - name: Trigger netdata/website update-integrations workflow
        if: steps.label-check.outputs.has_label == 'true'
        uses: benc-uk/workflow-dispatch@v1
        with:
          token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
          repo: netdata/website
          workflow: Update integrations
          ref: refs/heads/master