Official Images Updates Comment #28
This file contains hidden or 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: Official Images Updates Comment | |
| on: | |
| workflow_run: | |
| workflows: ["Official Images Updates"] | |
| types: | |
| - completed | |
| permissions: | |
| actions: read | |
| pull-requests: write | |
| jobs: | |
| comment: | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event.workflow_run.event == 'pull_request' && | |
| github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: pr-comment-data | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| - name: Post comment | |
| uses: actions/github-script@v9 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const prNumber = fs.readFileSync('pr_number.txt', 'utf8').trim(); | |
| const diff = fs.readFileSync('diff.txt', 'utf8').trim(); | |
| if (!diff) { | |
| console.log('No diff found, skipping comment.'); | |
| return; | |
| } | |
| const body = `<details> | |
| <summary>Library file diff (ignoring commit IDs)</summary> | |
| \`\`\`diff | |
| ${diff} | |
| \`\`\` | |
| </details>`; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: parseInt(prNumber), | |
| body: body | |
| }); |