name: Node-CI Beta

on:
  push:
    branches: [beta-*.*.*, beta]
  release:
    types: [prereleased]
  workflow_dispatch:

jobs:
  build_and_test:
    uses: donavanbecker/.github/.github/workflows/nodejs-build-and-test.yml@latest
    with:
      enable_coverage: true
    secrets:
      token: ${{ secrets.GITHUB_TOKEN }}
  lint:
    needs: build_and_test
    uses: donavanbecker/.github/.github/workflows/eslint.yml@latest

  publish:
    needs: lint

    if: ${{ github.repository == 'donavanbecker/homebridge-august' }}

    uses: donavanbecker/.github/.github/workflows/npm-publish.yml@latest
    with:
      tag: 'beta'
      dynamically_adjust_version: true
      npm_version_command: 'pre'
      pre_id: 'beta'
    secrets:
      npm_auth_token: ${{ secrets.npm_token }}

  github-releases-to-discord:
    needs: publish

    if: ${{ github.repository == 'donavanbecker/homebridge-august' && github.event.release.prerelease == true }}

    uses: OpenWonderLabs/.github/.github/workflows/discord-webhooks.yml@latest
    with:
      footer_title: "August"
    secrets:
      DISCORD_WEBHOOK_URL_LATEST: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }}
      DISCORD_WEBHOOK_URL_BETA: ${{ secrets.DISCORD_WEBHOOK_URL_BETA }}
