Skip to content

chore: update pkg.pr.new workflow #1055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/pkg.pr.new-comment.yml
Original file line number Diff line number Diff line change
@@ -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})
19 changes: 12 additions & 7 deletions .github/workflows/pkg.pr.new.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ on:
branches: [main]
tags: ['!**']

permissions:
issues: write
pull-requests: write

jobs:
build:
if: github.repository == 'sveltejs/eslint-plugin-svelte'
Expand All @@ -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 .