name: 'Release: Send version release notification'
run-name: 'Send version release notification for n8n@${{ inputs.version }}'

on:
  workflow_dispatch:
    inputs:
      previous-version:
        description: 'The previous release version (e.g. 2.10.2)'
        required: true
        type: string
      version:
        description: 'The release version (e.g. 2.11.0)'
        required: true
        type: string
  workflow_call:
    inputs:
      previous-version:
        description: 'The previous release version (e.g. 2.10.2)'
        required: true
        type: string
      version:
        description: 'The release version (e.g. 2.11.0)'
        required: true
        type: string

jobs:
  release-notification:
    runs-on: ubuntu-slim
    environment: release
    steps:
      - name: Checkout
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          fetch-depth: 1

      - name: Setup Node.js
        uses: ./.github/actions/setup-nodejs
        with:
          build-command: ''
          install-command: pnpm install --frozen-lockfile --dir ./.github/scripts --ignore-workspace
          cache-dependency-path: .github/scripts/pnpm-lock.yaml

      - name: Send release notification
        env:
          N8N_VERSION_RELEASE_NOTIFICATION_DATA: ${{ secrets.N8N_VERSION_RELEASE_NOTIFICATION_DATA }}
          PAYLOAD: |
            {
              "previous_version": "${{ inputs.previous-version }}",
              "new_version": "${{ inputs.version }}"
            }
        run: node ./.github/scripts/send-version-release-notification.mjs
