mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-17 14:28:25 +00:00
refactor(ci): move PR title generation into a composite action
Move `scripts/generatePullRequestTitle.mts` and its test into `.github/actions/generate-pr-title`, a composite action with its own workspace package that returns the generated title as its `title` output. The workflow now calls the local action, and `test:scripts` runs the action package's tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K55QQNMU98yovHirwTxsCD
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
name: Generate PR title
|
||||
description: Generates a conventional-commit title for a pull request from the files it adds and changes.
|
||||
|
||||
inputs:
|
||||
added-files:
|
||||
description: Space-separated list of files the pull request adds.
|
||||
required: true
|
||||
changed-files:
|
||||
description: Space-separated list of all files the pull request changes (added, modified, renamed and deleted).
|
||||
required: true
|
||||
current-title:
|
||||
description: Current title of the pull request.
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
title:
|
||||
description: The new title, or an empty string when no change is needed.
|
||||
value: ${{ steps.generate.outputs.title }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Generate PR title
|
||||
id: generate
|
||||
shell: bash
|
||||
# The inputs are passed through `env` rather than inlined into the script,
|
||||
# because the current title is written by the PR author.
|
||||
run: |
|
||||
NEW_TITLE="$(node "$GITHUB_ACTION_PATH/generatePullRequestTitle.mts")"
|
||||
{
|
||||
echo "title<<PR_TITLE_EOF"
|
||||
echo "$NEW_TITLE"
|
||||
echo "PR_TITLE_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
ADDED_FILES: ${{ inputs.added-files }}
|
||||
CHANGED_FILES: ${{ inputs.changed-files }}
|
||||
CURRENT_TITLE: ${{ inputs.current-title }}
|
||||
+6
-6
@@ -6,11 +6,11 @@
|
||||
* for icon contributions and, for every other kind of PR, inserts or updates the
|
||||
* conventional-commit scope so `lint-pr-title` is satisfied.
|
||||
*
|
||||
* It follows the convention of `generateChangedIconsCommentMarkup.mts`: it reads
|
||||
* its input from the environment, prints the result to stdout and has no other
|
||||
* side effects. It only imports Node built-ins and the shared
|
||||
* `conventional-commit-types.json` (a native JSON import), so Node can still run
|
||||
* it natively as an `.mts` file without a `pnpm install` step.
|
||||
* It runs as the `generate-pr-title` composite action: it reads its input from
|
||||
* the environment, prints the result to stdout and has no other side effects.
|
||||
* It only imports Node built-ins and the shared `conventional-commit-types.json`
|
||||
* (a native JSON import), so Node can still run it natively as an `.mts` file
|
||||
* without a `pnpm install` step.
|
||||
*
|
||||
* Env input (CLI wrapper at the bottom):
|
||||
* - `ADDED_FILES_FILE`: path to a newline-separated list of added files, or
|
||||
@@ -26,7 +26,7 @@ import { readFileSync } from 'node:fs';
|
||||
|
||||
// Single source of truth for the conventional-commit types, shared with
|
||||
// `lint-pr-title` (amannn/action-semantic-pull-request).
|
||||
import VALID_TYPES from '../.github/conventional-commit-types.json' with { type: 'json' };
|
||||
import VALID_TYPES from '../../conventional-commit-types.json' with { type: 'json' };
|
||||
|
||||
// Default type used in prefix mode when the current title has no valid type.
|
||||
// The path reliably tells us the scope but nothing about whether a change is a
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@lucide/generate-pr-title-action",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "GitHub action that generates a conventional-commit title for a pull request from the files it changes",
|
||||
"scripts": {
|
||||
"start": "node ./generatePullRequestTitle.mts",
|
||||
"test": "node --test *.test.mts"
|
||||
}
|
||||
}
|
||||
@@ -48,25 +48,19 @@ jobs:
|
||||
|
||||
- name: Generate PR title
|
||||
id: generate
|
||||
run: |
|
||||
NEW_TITLE="$(node ./scripts/generatePullRequestTitle.mts)"
|
||||
{
|
||||
echo "new_title<<PR_TITLE_EOF"
|
||||
echo "$NEW_TITLE"
|
||||
echo "PR_TITLE_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
|
||||
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
|
||||
CURRENT_TITLE: ${{ github.event.pull_request.title }}
|
||||
uses: ./.github/actions/generate-pr-title
|
||||
with:
|
||||
added-files: ${{ steps.changed-files.outputs.added_files }}
|
||||
changed-files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
|
||||
current-title: ${{ github.event.pull_request.title }}
|
||||
|
||||
- name: Update PR title
|
||||
if: steps.generate.outputs.new_title != ''
|
||||
if: steps.generate.outputs.title != ''
|
||||
run: gh pr edit "$PR_NUMBER" --title "$NEW_TITLE"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
NEW_TITLE: ${{ steps.generate.outputs.new_title }}
|
||||
NEW_TITLE: ${{ steps.generate.outputs.title }}
|
||||
|
||||
# Runs after the title is generated: an edit made with `GITHUB_TOKEN` does not
|
||||
# trigger new workflow runs, so a separate workflow would lint the old title.
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
"test:integrations:vue": "pnpm --filter @lucide/vue build && pnpm -r --workspace-concurrency=1 --filter './integrations/lucide-vue/**' check",
|
||||
"test:integrations:svelte": "pnpm --filter @lucide/svelte build && pnpm -r --workspace-concurrency=1 --filter './integrations/lucide-svelte/**' check",
|
||||
"test:font": "pnpm --filter build-font test",
|
||||
"test:scripts": "node --test scripts/*.test.mts",
|
||||
"test:scripts": "pnpm --filter @lucide/generate-pr-title-action test",
|
||||
"lucide": "pnpm --filter lucide",
|
||||
"lucide-angular": "pnpm --filter lucide-angular",
|
||||
"lucide-react": "pnpm --filter lucide-react",
|
||||
|
||||
Generated
+2
@@ -123,6 +123,8 @@ importers:
|
||||
specifier: ^18.1.0
|
||||
version: 18.2.0
|
||||
|
||||
.github/actions/generate-pr-title: {}
|
||||
|
||||
.github/actions/suggest-metadata:
|
||||
dependencies:
|
||||
'@octokit/rest':
|
||||
|
||||
Reference in New Issue
Block a user