From b9f83cc9640ed8ab13a91c9921dacc7f3a8be59b Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Thu, 6 Feb 2025 08:31:25 +0900 Subject: [PATCH 1/2] chore: update pkg.pr.new workflow --- .github/workflows/pkg.pr.new-comment.yml | 31 ++++++++++++++++++++++++ .github/workflows/pkg.pr.new.yml | 21 ++++++++++------ 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/pkg.pr.new-comment.yml diff --git a/.github/workflows/pkg.pr.new-comment.yml b/.github/workflows/pkg.pr.new-comment.yml new file mode 100644 index 000000000..1b0e4b6fd --- /dev/null +++ b/.github/workflows/pkg.pr.new-comment.yml @@ -0,0 +1,31 @@ +name: Update pkg.pr.new comment + +on: + workflow_run: + workflows: ['Publish to pkg.pr.new'] + types: + - completed + +jobs: + build: + if: github.repository == 'sveltejs/eslint-plugin-svelte' + name: 'Update comment' + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: output + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + - run: ls -R . + - name: 'Post or update comment' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + const output = JSON.parse(fs.readFileSync('output.json', 'utf8')); + const { default: process } = await import('${{ github.workspace }}/tools/pkg.pr.new-comment.mjs') + + await process({github, context, core, output}) diff --git a/.github/workflows/pkg.pr.new.yml b/.github/workflows/pkg.pr.new.yml index c6037997f..f8734f809 100644 --- a/.github/workflows/pkg.pr.new.yml +++ b/.github/workflows/pkg.pr.new.yml @@ -1,4 +1,4 @@ -name: Publish to pkg.pr.new +name: Publish Any Commit on: pull_request: branches: [main] @@ -6,10 +6,6 @@ on: branches: [main] tags: ['!**'] -permissions: - issues: write - pull-requests: write - jobs: build: if: github.repository == 'sveltejs/eslint-plugin-svelte' @@ -24,12 +20,21 @@ jobs: - name: Build run: pnpm run build - run: pnpx pkg-pr-new publish --compact './packages/eslint-plugin-svelte' --json output.json --comment=off - - uses: actions/github-script@v7 + - name: Add metadata to output + uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const fs = require('fs'); const output = JSON.parse(fs.readFileSync('output.json', 'utf8')); - const { default: process } = await import('${{ github.workspace }}/tools/pkg.pr.new-comment.mjs') + output.number = context.issue.number; + output.event_name = context.eventName; + output.ref = context.ref; + fs.writeFileSync('output.json', JSON.stringify(output), 'utf8'); + - name: Upload output + uses: actions/upload-artifact@v4 + with: + name: output + path: ./output.json - await process({github, context, core, output}) + - run: ls -R . From 6994a5a979420714b72748257fec0aef54efb708 Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Thu, 6 Feb 2025 08:37:37 +0900 Subject: [PATCH 2/2] revert workflow name --- .github/workflows/pkg.pr.new.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pkg.pr.new.yml b/.github/workflows/pkg.pr.new.yml index f8734f809..4f2977c15 100644 --- a/.github/workflows/pkg.pr.new.yml +++ b/.github/workflows/pkg.pr.new.yml @@ -1,4 +1,4 @@ -name: Publish Any Commit +name: Publish to pkg.pr.new on: pull_request: branches: [main]