name: Push & Release 🌍

concurrency:
  group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref }}
  cancel-in-progress: true

on:
  push:
    branches:
      - master
      - release*
    paths-ignore:
      - '**/*.md'

jobs:
  main:
    name: 'Unstable release 🚀⚠️'
    uses: ./.github/workflows/__package.yml
    with:
      commit: ${{ github.sha }}

  quality_checks:
    name: Quality checks 👌🧪
    if: ${{ always() && !cancelled() }}
    uses: ./.github/workflows/__quality_checks.yml
    permissions: {}
    with:
      commit: ${{ github.sha }}

  codeql:
    name: GitHub CodeQL 🔬
    uses: ./.github/workflows/__codeql.yml
    permissions:
      actions: read
      contents: read
      security-events: write
    with:
      commit: ${{ github.sha }}

  deploy:
    name: Deploy 🚀
    if: ${{ github.repository == 'jellyfin/jellyfin-web' }}
    uses: ./.github/workflows/__deploy.yml
    needs:
      - main
    permissions:
      contents: read
      deployments: write
    secrets:
      JF_BOT_TOKEN: ${{ secrets.JF_BOT_TOKEN }}
      CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
      CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
    with:
      branch: ${{ github.ref_name }}
      commit: ${{ github.sha }}
      workflow_run_id: ${{ github.run_id }}
      comment: false
