Skip to content

Build Asset Comment for Pull Request #10505

Build Asset Comment for Pull Request

Build Asset Comment for Pull Request #10505

name: Build Asset Comment for Pull Request
on:
workflow_run:
workflows: [Kolibri Build Assets for Pull Request]
types:
- completed
permissions:
contents: read
pull-requests: write
actions: read
jobs:
post:
name: Add build artifact PR comment
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'cancelled' }}
steps:
- uses: actions/checkout@v7.0.1
- name: Find PR by head SHA
id: find-pr
uses: actions/github-script@v9
with:
script: |
const utils = require('./.github/githubUtils.js')
const prNumber = await utils.findPrByHeadSha(github, context)
if (!prNumber) {
core.notice('No open PR found for head SHA; skipping comment')
core.setOutput('found', 'false')
return null
}
core.setOutput('found', 'true')
return prNumber
- name: Post build comment
if: steps.find-pr.outputs.found == 'true'
uses: actions/github-script@v9
env:
PR_NUMBER: ${{ steps.find-pr.outputs.result }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const utils = require('./.github/githubUtils.js')
const prNumber = Number(process.env.PR_NUMBER)
const body = await utils.generateAssetComment(github, context)
await utils.upsertComment(github, context, prNumber, '**Build Artifacts**', body)