Files
lucide/.github/workflows/pull-request-icon-preview.yml
T
Eric FennisandClaude 3a699de8e6 ci(icon-preview): Show icon previews in the PR description (#5338)
* ci: show icon previews in the PR description

Replace the icon-preview comment action with a workflow that writes a
preview image per added or changed icon into the PR description, between
the "Icon preview" markers from the PR template. The images are served by
review.lucide.dev, so the workflow no longer needs dependencies or the
PR's SVGs.

- scripts/updatePullRequestDescriptionPreview.mts renders the markup and
  replaces it between the markers (idempotent, keeps CRLF bodies and the
  surrounding text as is), and updates the body through the REST API.
- .github/workflows/pull-request-description-preview.yml runs it on
  pull_request_target from the base branch only.
- Add the "Icon preview" section with the markers to the PR template.
- Remove the pull-request-icon-preview workflow and the icon-preview action.

Co-Authored-By: Claude <noreply@anthropic.com>

* ci: move the PR description preview into the icon-preview action

Move the description preview script and its tests from scripts/ into
.github/actions/icon-preview, a composite action like the old one, with a
package.json (start, debug, test) and an .env.example for local runs. The
workflow now calls the action with the PR number, head SHA, changed files
and token as inputs.

Co-Authored-By: Claude <noreply@anthropic.com>

* ci: adjust the icon-preview action instead of adding a new workflow

Restore the icon-preview action and its workflow from main and adjust
them in place: the action now runs updatePullRequestDescriptionPreview.mts
(Node built-ins only, so no dependencies or install step) to write the
previews into the PR description, and the workflow calls it with the PR
number, head SHA, changed files and token. The separate
pull-request-description-preview workflow is removed.

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(icon-preview): remove a lone marker before adding a fresh pair

When only the start or the end marker is left in the description, remove
it (with its line break) before prepending a new marker pair, so the
body never keeps an orphan marker.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-30 14:06:14 +01:00

57 lines
1.9 KiB
YAML

name: Pull request icon preview
on:
pull_request_target:
types:
- opened
- reopened
- synchronize
- edited
paths:
- 'icons/*.svg'
permissions: {}
concurrency:
group: icon-preview-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
icon-preview:
name: Icon Preview
if: github.repository == 'lucide-icons/lucide'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write # Required to edit the PR description
steps:
# We check out the main branch of the main repository for security reasons.
# The action only gets the changed file names and the head SHA as inputs, so no
# code from the (untrusted) pull request is checked out or run.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: lucide-icons/lucide
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: 'package.json'
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6
with:
files: icons/*.svg
# The checkout is the base branch, so the PR head commit isn't available locally.
use_rest_api: true
- name: Update PR description
uses: ./.github/actions/icon-preview
with:
pr-number: ${{ github.event.pull_request.number }}
head-sha: ${{ github.event.pull_request.head.sha }}
added-files: ${{ steps.changed-files.outputs.added_files }}
# Added, copied, modified and renamed files; deleted icons are left out.
changed-files: ${{ steps.changed-files.outputs.all_changed_files }}
github-token: ${{ secrets.GITHUB_TOKEN }}