Skip to content

feat: add cca deployment [skip-line-limit] #6973

feat: add cca deployment [skip-line-limit]

feat: add cca deployment [skip-line-limit] #6973

name: Validate PR Title
on:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
validate-pr-title:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install commitlint globally
run: |
npm install -g @commitlint/config-conventional @commitlint/cli
- name: Create commitlint config
run: |
cat > commitlint.config.js << 'EOF'
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat',
'fix',
'chore',
'refactor',
'docs',
'test'
]
],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'header-max-length': [2, 'always', 72]
}
};
EOF
- name: Validate PR title
run: |
PR_TITLE="${{ github.event.pull_request.title }}"
echo "PR Title: $PR_TITLE"
if echo "$PR_TITLE" | commitlint --verbose; then
echo "✅ PR title passed validation"
else
echo "❌ PR title failed validation"
exit 1
fi
- name: Comment on PR if validation fails
if: failure()
uses: actions/github-script@v7
with:
script: |
// First, check if we already commented on this PR
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('PR Title Validation Failed')
);
const commentBody = `## ❌ PR Title Validation Failed
Your PR title doesn't follow the [Conventional Commits](https://www.conventionalcommits.org/) specification.
**Current title:** \`${{ github.event.pull_request.title }}\`
Please ensure your PR title follows this format:
\`\`\`
<type>[optional scope]: <description>
\`\`\`
**Valid types:** feat, fix, chore, refactor, docs, test
**Examples:**
- \`feat: add new encryption provider\`
- \`fix(cli): resolve template initialization bug\`
- \`chore(ci): update GitHub Actions\`
- \`feat!: breaking change to API\`
Please update your PR title to follow this format.`;
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}
- name: Remove validation comment if title is valid
if: success()
uses: actions/github-script@v7
with:
script: |
// Remove any existing validation failure comments if the title is now valid
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('PR Title Validation Failed')
);
if (botComment) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id
});
}