name: Pull Request Labeled

on:
  pull_request_target:
    types: [labeled]

# SECURITY: This workflow uses pull_request_target and has access to secrets.
# Do NOT checkout or run code from the PR head. All code execution must use
# the base branch only. Adding a ref to PR head would expose secrets to
# untrusted code.
permissions: {}

jobs:
  pull-request-labeled-backport-requested:
    name: backport/requested label added
    if: github.event.label.name == 'backport/requested 🗳'
    runs-on: ubuntu-latest
    permissions: {}
    steps:
      - name: Trigger Slack workflow
        uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
        with:
          webhook: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }} 
          webhook-type: webhook-trigger
          payload: |
            {
              "base_ref": ${{ toJSON(github.event.pull_request.base.ref) }},
              "title": ${{ toJSON(github.event.pull_request.title) }},
              "url": ${{ toJSON(github.event.pull_request.html_url) }},
              "user": ${{ toJSON(github.event.pull_request.user.login) }}
            }
  pull-request-labeled-deprecation-review-complete:
    name: deprecation-review/complete label added
    if: github.event.label.name == 'deprecation-review/complete ✅'
    runs-on: ubuntu-latest
    permissions: {}
    steps:
      - name: Generate GitHub App token
        uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
        id: generate-token
        with:
          creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
          org: electron
      - name: Set status
        uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
        with:
          token: ${{ steps.generate-token.outputs.token }}
          project-number: 94
          field: Status
          field-value: ✅ Reviewed
