Update pkg.pr.new comment #1535
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: Update pkg.pr.new comment | |
| # This workflow is used to comment a pull request with a package created in pkg.pr.new.yml. | |
| # | |
| # The GITHUB_TOKEN for the workflow from a pull request | |
| # does not have the permission to comment on the pull request, | |
| # so the workflow is split. | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| on: | |
| workflow_run: | |
| workflows: [Publish to pkg.pr.new] | |
| types: | |
| - completed | |
| jobs: | |
| build: | |
| if: github.repository == 'stylelint/stylelint' | |
| name: Update comment | |
| runs-on: ubuntu-slim | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: latest | |
| cache: npm | |
| - name: Install Packages | |
| run: npm ci | |
| - name: Create artifacts directory | |
| run: mkdir -p ${{ runner.temp }}/artifacts/ | |
| - name: Download artifact | |
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: output | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| path: ${{ runner.temp }}/artifacts/ | |
| - name: Check artifacts directory | |
| run: ls -R ${{ runner.temp }}/artifacts/ | |
| - name: Post or update comment | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const fs = require('fs'); | |
| const output = JSON.parse(fs.readFileSync('${{ runner.temp }}/artifacts/output.json', 'utf8')); | |
| const { postCustomComment } = await import('${{ github.workspace }}/scripts/pkg.pr.new-custom-comment.mjs') | |
| await postCustomComment({github, context, core, output}) |