name: Release Drafter

on:
  push:
    branches:
      - master
  workflow_dispatch:

permissions:
  contents: read

jobs:
  correct_repository:
    permissions:
      contents: none
    runs-on: ubuntu-latest
    steps:
    - name: fail on fork
      if: github.repository_owner != 'chartjs'
      run: exit 1

  update_release_draft:
    permissions:
      contents: write  # for release-drafter/release-drafter to create a github release
      pull-requests: write  # for release-drafter/release-drafter to add label to PR
    needs: correct_repository
    runs-on: ubuntu-latest
    steps:
      - uses: release-drafter/release-drafter@v6
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
