Compare commits
1 commit
main
...
refactor/g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be33c468ee |
7 changed files with 64 additions and 20 deletions
38
.github/actions/generate-pr-title/action.yml
vendored
Normal file
38
.github/actions/generate-pr-title/action.yml
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
name: Generate PR title
|
||||
description: Generates a conventional-commit pull request title from the files the pull request 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 adds, modifies, renames or deletes.
|
||||
required: true
|
||||
current-title:
|
||||
description: The current pull request title.
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
title:
|
||||
description: The new pull request title, or an empty string when the title should stay as it is.
|
||||
value: ${{ steps.generate.outputs.title }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Generate PR title
|
||||
id: generate
|
||||
shell: bash
|
||||
# The inputs reach the script through `env`, never inlined into `run`: the
|
||||
# current title is written by the PR author and would allow script injection.
|
||||
run: |
|
||||
TITLE="$(node "$GITHUB_ACTION_PATH/generatePullRequestTitle.mts")"
|
||||
{
|
||||
echo "title<<PR_TITLE_EOF"
|
||||
echo "$TITLE"
|
||||
echo "PR_TITLE_EOF"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
ADDED_FILES: ${{ inputs.added-files }}
|
||||
CHANGED_FILES: ${{ inputs.changed-files }}
|
||||
CURRENT_TITLE: ${{ inputs.current-title }}
|
||||
|
|
@ -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 the icon-preview action script: 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
|
||||
10
.github/actions/generate-pr-title/package.json
vendored
Normal file
10
.github/actions/generate-pr-title/package.json
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "@lucide/generate-pr-title-action",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "GitHub action that generates a conventional-commit pull request title from the files a pull request changes",
|
||||
"scripts": {
|
||||
"start": "node ./generatePullRequestTitle.mts",
|
||||
"test": "node --test *.test.mts"
|
||||
}
|
||||
}
|
||||
20
.github/workflows/generate-pr-title.yml
vendored
20
.github/workflows/generate-pr-title.yml
vendored
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ importers:
|
|||
specifier: ^18.2.0
|
||||
version: 18.2.0
|
||||
|
||||
.github/actions/generate-pr-title: {}
|
||||
|
||||
.github/actions/icon-preview:
|
||||
dependencies:
|
||||
'@lucide/helpers':
|
||||
|
|
|
|||
Loading…
Reference in a new issue