name: Add Comment with Diffend.io Links to PR
on:
  workflow_run:
    workflows: ['Create Diffend.io Links and Comment Text']
    types:
      - completed
permissions:
  contents: read
jobs:
  comment_diffend_io_links_to_pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - name: Download artifacts
        uses: dawidd6/action-download-artifact@v16
        with:
          workflow: ${{ github.event.workflow_run.workflow_id }}
          workflow_conclusion: success
      - name: Fetch PR number from artifacts
        run: |
          echo "pr_number=$(cat comment_text_and_pr_number/pr_number.txt)" >> $GITHUB_ENV
      - name: Add Comment to PR
        uses: thollander/actions-comment-pull-request@v3
        with:
          file-path: comment_text_and_pr_number/comment_text.txt
          pr-number: ${{ env.pr_number }}
          comment-tag: comment_with_diffend_io_links
