name: issue-labels

on:
  pull_request_target:
    types:
      - edited
      - synchronize
      - labeled

env:
  RNA_VERSION: v1.6.1 # renovate: datasource=forgejo-releases depName=forgejo/release-notes-assistant registryUrl=https://code.forgejo.org

jobs:
  release-notes:
    if: ( vars.ROLE == 'forgejo-coding' ) && contains(github.event.pull_request.labels.*.name, 'worth a release-note')
    runs-on: docker
    container:
      image: 'data.forgejo.org/oci/ci:1'
    steps:
      - uses: https://data.forgejo.org/actions/checkout@v6

      - name: event
        run: |
          cat <<'EOF'
          ${{ toJSON(github.event.pull_request.labels.*.name) }}
          EOF
          cat <<'EOF'
          ${{ toJSON(github.event) }}
          EOF

      - name: install release-notes-assistant
        run: |
          set -x
          wget -O /usr/local/bin/rna https://code.forgejo.org/forgejo/release-notes-assistant/releases/download/${{ env.RNA_VERSION}}/release-notes-assistant
          chmod +x /usr/local/bin/rna

      - name: release-notes-assistant preview
        run: |
          rna --config .release-notes-assistant.yaml --storage pr --storage-location ${{ github.event.pull_request.number }} --forgejo-url $GITHUB_SERVER_URL --repository $GITHUB_REPOSITORY --token ${{ secrets.RELEASE_NOTES_ASSISTANT_TOKEN }} preview ${{ github.event.pull_request.number }}
