diff --git a/.github/conventional-commit-types.json b/.github/conventional-commit-types.json new file mode 100644 index 000000000..c63ef34d1 --- /dev/null +++ b/.github/conventional-commit-types.json @@ -0,0 +1,12 @@ +[ + "fix", + "feat", + "perf", + "refactor", + "test", + "style", + "docs", + "ci", + "build", + "chore" +] diff --git a/.github/workflows/generate-pr-title.yml b/.github/workflows/generate-pr-title.yml new file mode 100644 index 000000000..0e70e0462 --- /dev/null +++ b/.github/workflows/generate-pr-title.yml @@ -0,0 +1,103 @@ +name: PR title + +on: + pull_request_target: + types: + - opened + - reopened + - synchronize + - edited + +permissions: {} + +concurrency: + group: pr-title-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + generate-pr-title: + name: Generate PR Title + # Skip when a maintainer has opted out by adding the "Keep PR title" label, + # and on manual edits so they are not reverted straight away. + if: github.repository == 'lucide-icons/lucide' && + github.event.action != 'edited' && + !contains(github.event.pull_request.labels.*.name, 'Keep PR title') + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write # Required to edit the PR title + + steps: + # We check out the main branch of the main repository for security reasons. + # The script only reads its input from the environment, so it never runs + # any code from the (untrusted) pull request. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + repository: lucide-icons/lucide + fetch-depth: 0 + - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version-file: 'package.json' + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6 + with: + # The checkout is the base branch, so the PR head commit isn't available locally. + use_rest_api: true + + - name: Generate PR title + id: generate + run: | + NEW_TITLE="$(node ./scripts/generatePullRequestTitle.mts)" + { + echo "new_title<> "$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 }} + + - name: Update PR title + if: steps.generate.outputs.new_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 }} + + # 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. + # The lint action fetches the current title through the API. + lint-pr-title: + name: PR Title Lint + needs: generate-pr-title + if: ${{ !cancelled() }} + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read # Required to read the PR title + + steps: + # Checks out the base branch, so the allowed types can't be changed by the PR. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Read conventional commit types + id: commit-types + run: | + { + echo "types<> "$GITHUB_OUTPUT" + + - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: ${{ steps.commit-types.outputs.types }} + requireScope: true + ignoreLabels: | + bot diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml deleted file mode 100644 index ef9abcf61..000000000 --- a/.github/workflows/lint-pr-title.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Linting PR title - -on: - pull_request: - types: - - opened - - edited - - reopened - -permissions: - contents: read - pull-requests: read # Required to read the PR title - -jobs: - lint-pr-title: - name: PR Title Lint - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - types: | - fix - feat - perf - refactor - test - style - docs - ci - build - chore - requireScope: true - ignoreLabels: | - bot diff --git a/.prettierignore b/.prettierignore index 434e0d3a8..8dd5aedd3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,5 @@ pnpm-lock.yaml +.github/conventional-commit-types.json # docs examples docs/**/examples/ diff --git a/docs/.vitepress/theme/components/base/FakeInput.vue b/docs/.vitepress/theme/components/base/FakeInput.vue index e9fb2f811..a3f0fde03 100644 --- a/docs/.vitepress/theme/components/base/FakeInput.vue +++ b/docs/.vitepress/theme/components/base/FakeInput.vue @@ -27,7 +27,7 @@ defineProps({