Bump vite from 6.0.7 to 6.0.9 #395
Workflow file for this run
This file contains 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: PR Helper | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
permissions: | |
pull-requests: write | |
jobs: | |
screenshot: | |
runs-on: ubuntu-latest | |
name: Screenshot | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .node-version | |
registry-url: 'https://registry.npmjs.org' | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Take Screenshot | |
id: screenshot | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
run: | | |
sha="$GITHUB_SHA" | |
pnpm install | |
git fetch origin | |
networks=$( | |
git diff --name-only origin/$GITHUB_BASE_REF \ | |
| grep db/ \ | |
| sed -E 's/db\/(.*)[.]json/\1/' | |
) | |
mkdir -p build | |
./cli build:visual | |
pnpm vite preview \ | |
--host 0.0.0.0 \ | |
--port 4173 \ | |
--strictPort \ | |
-c test/visual/vite.config.js \ | |
-l silent \ | |
"test/visual" \ | |
& | |
pid="$!" | |
scale=2 | |
pnpx playwright install | |
for network in $networks | |
do | |
pnpx playwright screenshot \ | |
--viewport-size="$((850 * $scale)), $((400 * $scale))" \ | |
"http://localhost:4173?network=$network&knobs=false&scale=$scale" \ | |
"./build/$network.png" | |
done | |
pnpx playwright screenshot \ | |
--full-page \ | |
"http://localhost:4173?knobs=false&scale=$scale" \ | |
"./build/index.png" | |
kill $pid | |
link_networks="" | |
for network in $networks | |
do | |
pnpm wrangler r2 object put \ | |
-f ./build/$network.png \ | |
react-social-icons/pr-images/$sha/$network.png | |
link_networks="$link_networks,https://static.react-social-icons.com/pr-images/$sha/$network.png" | |
done | |
pnpm wrangler r2 object put \ | |
-f ./build/index.png \ | |
react-social-icons/pr-images/$sha/index.png | |
link_index="https://static.react-social-icons.com/pr-images/$sha/index.png" | |
echo "link_networks=$link_networks" >> $GITHUB_OUTPUT | |
echo "link_index=$link_index" >> $GITHUB_OUTPUT | |
- name: Comment on PR with screenshots | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const link_networks = '${{ steps.screenshot.outputs.link_networks }}'.split(','); | |
const link_index = '${{ steps.screenshot.outputs.link_index }}' | |
github.rest.pulls.createReview({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.number, | |
event: 'COMMENT', | |
body: ` | |
<h1>Screenshots</h1> | |
${link_networks | |
.filter(link => link.length > 0) | |
.sort((a, b) => a.localeCompare(b)) | |
.map(link => { | |
const filename = link.replace(/^.*\//u, '') | |
const network = filename.replace('.png', '') | |
return ` | |
<details> | |
<summary> | |
${network} | |
</summary> | |
<img | |
src="${link}" | |
alt="screenshot of an updated social network" | |
/> | |
</details> | |
`; | |
}) | |
} | |
<details> | |
<summary>All Networks</summary> | |
<img | |
src="${link_index}" | |
alt="screenshot of all networks" | |
/> | |
</details> | |
`.replace(/^\s+/gm, '').trim() | |
}) |