Build Asset Comment for Pull Request #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Asset Comment for Pull Request | |
on: | |
workflow_run: | |
workflows: [Kolibri Build Assets for Pull Request] | |
types: | |
- completed | |
jobs: | |
post: | |
name: Add build artifact PR comment | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Make text for build comment | |
id: comment-text | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const utils = require('./.github/githubUtils.js') | |
return await utils.generateAssetComment(github, context) | |
- name: Unzip PR number artifact | |
run: unzip pr_number.zip | |
- name: Get PR number | |
id: pr-number | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs'); | |
const prNumber = Number(fs.readFileSync('./pr_number')); | |
return prNumber | |
- name: Find build comment | |
id: find-comment | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const utils = require('./.github/githubUtils.js') | |
return await utils.findComment(github, context, ${{steps.pr-number.outputs.result}}) | |
- name: Create build comment | |
if: ${{!steps.find-comment.outputs.result}} | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: ${{steps.pr-number.outputs.result}}, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: ${{ steps.comment-text.outputs.result }} | |
}) | |
- name: Update build comment | |
if: ${{steps.find-comment.outputs.result}} | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{steps.find-comment.outputs.result}}, | |
body: ${{ steps.comment-text.outputs.result }} | |
}) |