|
20 | 20 | with: |
21 | 21 | permission: write |
22 | 22 |
|
23 | | - - name: Find comment |
24 | | - id: find-comment |
25 | | - uses: peter-evans/find-comment@v3 |
26 | | - with: |
27 | | - issue-number: ${{ github.event.pull_request.number }} |
28 | | - comment-author: 'github-actions[bot]' |
29 | | - body-includes: <!-- This comment was auto-generated by GitHub Actions for the snapshot action --> |
30 | | - |
31 | | - - name: Create comment |
32 | | - id: comment |
33 | | - uses: peter-evans/create-or-update-comment@v4 |
34 | | - env: |
35 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
36 | | - with: |
37 | | - comment-id: ${{ steps.find-comment.outputs.comment-id }} |
38 | | - issue-number: ${{ github.event.pull_request.number }} |
39 | | - edit-mode: replace |
40 | | - body: | |
41 | | - <!-- This comment was auto-generated by GitHub Actions for the snapshot action --> |
42 | | -
|
43 | | - **Alright @${{ github.actor }}, I'm working on the snapshot!** |
44 | | -
|
45 | | - You can follow the progress [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). |
46 | | -
|
47 | 23 | - name: Checkout default branch |
48 | 24 | uses: actions/checkout@v4 |
49 | 25 |
|
|
68 | 44 |
|
69 | 45 | - name: Create snapshot |
70 | 46 | id: snapshot |
71 | | - run: | |
72 | | - snapshots=$(pnpx pkg-pr-new@0.0.17 publish --pnpm --comment=off ./packages/*) |
73 | | - echo "${snapshots}" |
74 | | - snapshots=$(echo "${snapshots}" | awk ' |
75 | | - /⚡️ Your npm packages are published./ \ |
76 | | - { found=1; next } found \ |
77 | | - { sub(/npm i/, "pnpm add"); print "\"" $0 "\"" } |
78 | | - ' | paste -sd ',') |
79 | | - echo "snapshots=[$snapshots]" >> $GITHUB_OUTPUT |
80 | | -
|
81 | | - - name: Update comment (success) |
82 | | - uses: actions/github-script@v7 |
83 | | - env: |
84 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
85 | | - with: |
86 | | - script: | |
87 | | - const commands = ${{ steps.snapshot.outputs.snapshots }}.map((snapshot) => { |
88 | | - const [package, installer] = snapshot.split(": ") |
89 | | - const header = `<b>${package}:</b><br />` |
90 | | - const content = "\n```sh\n" + installer + "\n```\n" |
91 | | - return [header, content].join("\n") |
92 | | - }) |
93 | | -
|
94 | | - const header = `<!-- This comment was auto-generated by GitHub Actions for the snapshot action -->\n\n` |
95 | | - + `**Good news @${{ github.actor }}, your snapshot has been published!**\n\n` |
96 | | - + `You can review the build log [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).\n\n` |
97 | | - + "Commit: ${{ github.event.pull_request.head.sha }}" |
98 | | -
|
99 | | - const packages = `<details><summary><b>Packages:</b></summary>\n\n${commands.join("\n")}\n\n</details>` |
100 | | -
|
101 | | - await github.rest.issues.updateComment({ |
102 | | - comment_id: ${{ steps.comment.outputs.comment-id }}, |
103 | | - owner: context.repo.owner, |
104 | | - repo: context.repo.repo, |
105 | | - body: `${header}\n\n${packages}` |
106 | | - }) |
107 | | -
|
108 | | - - name: Update comment (failure) |
109 | | - if: failure() |
110 | | - uses: peter-evans/create-or-update-comment@v4 |
111 | | - env: |
112 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
113 | | - with: |
114 | | - comment-id: ${{ steps.comment.outputs.comment-id }} |
115 | | - edit-mode: replace |
116 | | - body: | |
117 | | - <!-- This comment was auto-generated by GitHub Actions for the snapshot action --> |
118 | | -
|
119 | | - **Sorry @${{ github.actor }}, I failed to publish the snapshot!** |
120 | | -
|
121 | | - You can review the build log [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). |
| 47 | + run: pnpx pkg-pr-new@0.0.17 publish --pnpm --comment=off ./packages/* |
0 commit comments