mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-15 14:11:46 +00:00
ci: add PR label workflow (backport multiple PRs) (#485)
* ci: add PR title lint (#458) Signed-off-by: Andy Lee <andy.lee@suse.com> * ci: only run PR lint in PR stage (#471) Signed-off-by: Andy Lee <andy.lee@suse.com> * ci: auto add PR label workflow and script (#466) * ci: add auto PR label workflow and script Signed-off-by: Andy Lee <andy.lee@suse.com> * fix: bug fix prefix Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: update label mapping Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: read commitlint prefix from commitlint.config.js Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: rename to scripts/extract-release-label.mjs Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com> * ci: add .github/release.yml (#468) * ci: add release.yml Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: update release.yml Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com> * ci: correct set PR label script name (#476) * fix: set label script name Signed-off-by: Andy Lee <andy.lee@suse.com> * ci: rerun PR label after PR edited Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com> * ci: setup env using actions/setup (#478) * ci: setup env using actions/setup Signed-off-by: Andy Lee <andy.lee@suse.com> * ci: rerun lint if PR force push Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
4bae62d046
commit
65f4405d29
40
.github/release.yml
vendored
Normal file
40
.github/release.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
# .github/release.yml
|
||||
changelog:
|
||||
categories:
|
||||
- title: Features
|
||||
labels:
|
||||
- feat
|
||||
- title: Bug Fixes
|
||||
labels:
|
||||
- fix
|
||||
- title: Dependencies
|
||||
labels:
|
||||
- deps
|
||||
- title: Performance
|
||||
labels:
|
||||
- perf
|
||||
- title: Documentation
|
||||
labels:
|
||||
- docs
|
||||
- title: Style
|
||||
labels:
|
||||
- style
|
||||
- title: Build & Continuous Integration
|
||||
labels:
|
||||
- build
|
||||
- ci
|
||||
- title: Security
|
||||
labels:
|
||||
- security
|
||||
- title: Tests
|
||||
labels:
|
||||
- test
|
||||
- title: Refactoring
|
||||
labels:
|
||||
- refactor
|
||||
- title: Chores
|
||||
labels:
|
||||
- chore
|
||||
- title: Others
|
||||
labels:
|
||||
- other
|
||||
30
.github/workflows/release-label.yaml
vendored
Normal file
30
.github/workflows/release-label.yaml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: "[PR Management] Add PR Label"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [opened, reopened, edited]
|
||||
branches:
|
||||
- main
|
||||
- 'release-harvester-v*'
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
auto-assign-pr-label:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.base_ref }}
|
||||
- name: Setup Nodejs and yarn install
|
||||
uses: ./.github/actions/setup
|
||||
- name: Set PR label
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PR_LABEL=$(node ./scripts/extract-release-label.mjs "${{ github.event.pull_request.title }}")
|
||||
echo "PR_LABEL = $PR_LABEL"
|
||||
gh pr edit ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --add-label "$PR_LABEL"
|
||||
6
.github/workflows/run-lint.yaml
vendored
6
.github/workflows/run-lint.yaml
vendored
@ -7,6 +7,7 @@ on:
|
||||
- main
|
||||
- 'release-*'
|
||||
pull_request:
|
||||
types: [opened, reopened, edited, synchronize]
|
||||
branches:
|
||||
- main
|
||||
- 'release-*'
|
||||
@ -22,6 +23,11 @@ jobs:
|
||||
- name: Run tests
|
||||
uses: ./.github/actions/lint
|
||||
|
||||
- name: Validate PR title lint
|
||||
if: github.event_name == 'pull_request'
|
||||
shell: bash
|
||||
run: echo "${{ github.event.pull_request.title }}" | npx commitlint
|
||||
|
||||
- name: Validate commit messages
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
"prepare": "husky"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/load": "^19.8.1",
|
||||
"@commitlint/cli": "^19.8.1",
|
||||
"@commitlint/config-conventional": "^19.8.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
|
||||
16
scripts/extract-release-label.mjs
Normal file
16
scripts/extract-release-label.mjs
Normal file
@ -0,0 +1,16 @@
|
||||
/* eslint-disable no-console */
|
||||
import load from "@commitlint/load";
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
console.error('No PR title as first argument');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const prTitle = process.argv[2];
|
||||
const prLabel = prTitle.split(':')[0].trim();
|
||||
|
||||
const config = await load({ extends: ["./commitlint.config.js"] });
|
||||
const commitPrefix = config?.rules?.['type-enum']?.[2] || [];
|
||||
const label = commitPrefix.includes(prLabel) ? prLabel : 'other';
|
||||
|
||||
console.log(label);
|
||||
Loading…
x
Reference in New Issue
Block a user