mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-12 13:38:32 +00:00
* refactor(ci): move icon preview markup into a composite action Move generateChangedIconsCommentMarkup.mts into .github/actions/icon-preview as its own pnpm workspace package, following the suggest-metadata action. svgson and @lucide/helpers are now real dependencies installed with a filtered pnpm install, replacing the ad-hoc `npm install svgson --force`. Paths are resolved from the repo root relative to the script, so it also works through `pnpm --filter @lucide/icon-preview-action start`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(ci): skip icon preview comment when no icons changed When a pull request only deletes icons, CHANGED_FILES has no SVGs and the script printed "No changed icons found" to stdout, which was then posted as the preview comment. The script now logs that to stderr. The action writes no markup file and sets `has-changes=false`, the workflow skips the artifact upload, and the comment workflow skips its steps when no artifact exists instead of failing on the missing artifact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(icon-preview): post the preview comment from a pull_request_target workflow Like the PR title workflow, the icon preview now runs on pull_request_target and posts its comment directly, so comment-icon-preview.yml and the workflow_run artifact hand-off are removed. The job checks out the base branch and runs the action from there. The changed SVGs are read from the pull request head with `git fetch` + `git show` into a temp directory, so no code from the pull request is checked out or run. File names are checked against `icons/<kebab-case>.svg` before use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.6 KiB
YAML
73 lines
2.6 KiB
YAML
name: Pull request icon preview
|
|
|
|
on:
|
|
pull_request_target:
|
|
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 post the preview comment
|
|
|
|
steps:
|
|
# We check out the main branch of the main repository for security reasons.
|
|
# The changed SVGs are read from the pull request head as plain files with
|
|
# `git show`, 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: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
|
|
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
with:
|
|
cache: 'pnpm'
|
|
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: Install dependencies
|
|
run: pnpm install --frozen-lockfile --filter @lucide/icon-preview-action...
|
|
|
|
- name: Generate comment markup
|
|
id: comment-markup
|
|
uses: ./.github/actions/icon-preview
|
|
with:
|
|
changed-files: ${{ steps.changed-files.outputs.all_changed_files }}
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
output-file: ${{ runner.temp }}/comment-markup.md
|
|
|
|
- name: Find Comment
|
|
if: steps.comment-markup.outputs.has-changes == 'true'
|
|
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
|
|
id: pr-comment
|
|
with:
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
comment-author: 'github-actions[bot]'
|
|
body-includes: Added or changed icons
|
|
|
|
- name: Create or update comment
|
|
if: steps.comment-markup.outputs.has-changes == 'true'
|
|
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
|
|
with:
|
|
comment-id: ${{ steps.pr-comment.outputs.comment-id }}
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
body-path: ${{ runner.temp }}/comment-markup.md
|
|
edit-mode: replace
|