Skip to content

Comment on Pull Request with XML diff link #3

Comment on Pull Request with XML diff link

Comment on Pull Request with XML diff link #3

name: Comment on Pull Request with XML diff link
on:
workflow_run:
workflows: [DD XML diffs]
types: [completed]
permissions:
pull-requests: write # Required to comment on PRs
issues: write # Required for PR comments via issues API
jobs:
comment:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Comment on PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const jobs = await github.rest.actions.listJobsForWorkflowRunAttempt({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
attempt_number: context.payload.workflow_run.run_attempt
})
let job = jobs.data.jobs[jobs.data.jobs.length - 1]
github.rest.issues.createComment({
issue_number: context.payload.workflow_run.pull_requests[0].number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[Diff of generated Data Dictionary XML file](${{ github.server_url }}/${{ github.repository }}/actions/runs/${context.payload.workflow_run.id}/attempts/${context.payload.workflow_run.run_attempt}#summary-${job.id})`
})