Skip to content

Commit

Permalink
build: try new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD committed Mar 31, 2024
1 parent 9af5353 commit a6a87b8
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ changelog:
- breaking
- title: Features 🚀
labels:
- feature
- feat
- title: Bug Fixes 🐞
labels:
- fix
- bug
- title: Build System 🛠
labels:
- build
Expand All @@ -23,18 +25,22 @@ changelog:
- title: Documentation 📚
labels:
- docs
- documentation
- title: Enhancements 🌈
labels:
- enhancement
- title: Dependency Updates 📦
labels:
- chore
- dependencies
- title: Performance Improvements ⚡️
labels:
- perf
- performance
- title: Style 💅
labels:
- style
- lint
- title: Tests 🧪
labels:
- tests
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Label PR

on:
pull_request_target:
types:
- opened
branches:
- main

jobs:
add-pr-labels:
name: Add PR labels
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.repository == 'nuxt/nuxt'
steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
with:
script: |
const labelsToAdd = []
const pullRequest = {
number: ${{ github.event.pull_request.number }},
title: process.env.PULL_REQUEST_TITLE,
labelsNames: ${{ toJson(github.event.pull_request.labels.*.name) }}
}
// Select label based on the name of the base branch
const baseBranchLabelName = '3.x'
if (!pullRequest.labelsNames.includes(baseBranchLabelName)) {
labelsToAdd.push(baseBranchLabelName)
}
// Select label based on the type in PR title
const pullRequestTypeToLabelName = {
breaking: 'breaking',
feat: 'feature',
fix: 'bug',
build: 'build',
ci: 'ci',
docs: 'documentation',
enhancement: 'enhancement',
chore: 'chore',
perf: 'performance',
style: 'style',
tests: 'tests',
refactor: 'refactor',
revert: 'revert'
}
for (const [pullRequestType, labelName] of Object.entries(
pullRequestTypeToLabelName
)) {
if (
pullRequest.title.startsWith(pullRequestType) &&
!pullRequest.labelsNames.includes(
pullRequestTypeToLabelName[pullRequestType]
)
) {
labelsToAdd.push(labelName)
break
}
}
// Add selected labels
if (labelsToAdd.length > 0) {
github.rest.issues.addLabels({
issue_number: pullRequest.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsToAdd
})
}

0 comments on commit a6a87b8

Please sign in to comment.