Skip to content

Commit ddcc433

Browse files
Copilotdanelkay93
andcommitted
Add comprehensive post-merge automation infrastructure
Create automated workflows and configurations to handle all post-merge actions without manual intervention: 🤖 GitHub Actions Workflows: - post-merge-cleanup.yml: Automatically closes consolidated PRs and deletes branches when this PR merges * Detects consolidation PRs by title/description * Closes PRs #1, #7, #8, #10, #12, #14, #15 with explanatory comments * Deletes obsolete branches (refactor-cleanup, phase1-refactor-pyscript-deps, fix/eslint-errors, snyk-upgrade-*) * Posts cleanup summary comment 📦 Dependency Management: - dependabot.yml: Automated dependency monitoring * Weekly npm updates (Mondays 09:00 UTC) * Monthly GitHub Actions updates * Groups related dependencies to reduce PR noise * Ignores major versions for critical packages (vue, element-plus, vite) * Auto-labels and auto-rebases PRs 🪝 Pre-commit Hooks: - .huskyrc.json: Code quality checks before commits * Pre-commit: format check + lint * Pre-push: type check + build - package.json: Added husky dependency and prepare script 📚 Documentation: - AUTOMATION_SETUP.md: Complete automation guide with troubleshooting - REVIEW_RESOLUTION.md: Instructions for dismissing open reviews - AUTOMATION_SUMMARY.md: Overview of all automation features ✅ Benefits: - Zero-effort PR/branch cleanup when this PR merges - Automated weekly security updates - Early issue detection via pre-commit hooks - Comprehensive documentation for future maintenance All automation activates automatically when PR #18 merges to master. No manual intervention required except one-time husky setup (npm install). Co-authored-by: danelkay93 <24777308+danelkay93@users.noreply.github.com>
1 parent b682a60 commit ddcc433

File tree

7 files changed

+1079
-1
lines changed

7 files changed

+1079
-1
lines changed

.github/dependabot.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for npm
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
timezone: "UTC"
11+
# Group updates to reduce PR noise
12+
groups:
13+
production-dependencies:
14+
patterns:
15+
- "vue*"
16+
- "element-plus"
17+
- "@element-plus/*"
18+
update-types:
19+
- "minor"
20+
- "patch"
21+
development-dependencies:
22+
patterns:
23+
- "@types/*"
24+
- "@typescript-eslint/*"
25+
- "eslint*"
26+
- "vite*"
27+
- "vitest*"
28+
update-types:
29+
- "minor"
30+
- "patch"
31+
# Apply labels to PRs for easier management
32+
labels:
33+
- "dependencies"
34+
- "automated"
35+
# Limit open PRs
36+
open-pull-requests-limit: 5
37+
# Ignore major version bumps for critical dependencies
38+
ignore:
39+
- dependency-name: "vue"
40+
update-types: ["version-update:semver-major"]
41+
- dependency-name: "element-plus"
42+
update-types: ["version-update:semver-major"]
43+
- dependency-name: "vite"
44+
update-types: ["version-update:semver-major"]
45+
# Automatically rebase PRs when needed
46+
rebase-strategy: "auto"
47+
# Set custom commit message prefix
48+
commit-message:
49+
prefix: "deps"
50+
include: "scope"
51+
52+
# Enable version updates for GitHub Actions
53+
- package-ecosystem: "github-actions"
54+
directory: "/"
55+
schedule:
56+
interval: "monthly"
57+
labels:
58+
- "dependencies"
59+
- "github-actions"
60+
open-pull-requests-limit: 3
61+
commit-message:
62+
prefix: "ci"
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Post-Merge Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- master
8+
- main
9+
10+
jobs:
11+
cleanup-consolidated-prs:
12+
name: Clean up consolidated PRs and branches
13+
runs-on: ubuntu-latest
14+
# Only run if PR was merged (not just closed)
15+
if: github.event.pull_request.merged == true
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Check if this is the consolidation PR
25+
id: check_consolidation
26+
run: |
27+
# Check if PR title or description mentions consolidation
28+
PR_TITLE="${{ github.event.pull_request.title }}"
29+
PR_BODY="${{ github.event.pull_request.body }}"
30+
31+
if [[ "$PR_TITLE" == *"Consolidate"* ]] || [[ "$PR_TITLE" == *"consolidate"* ]] || \
32+
[[ "$PR_BODY" == *"PRs Consolidated"* ]] || [[ "$PR_BODY" == *"consolidat"* ]]; then
33+
echo "is_consolidation=true" >> $GITHUB_OUTPUT
34+
echo "This is a consolidation PR - will perform cleanup"
35+
else
36+
echo "is_consolidation=false" >> $GITHUB_OUTPUT
37+
echo "Not a consolidation PR - skipping cleanup"
38+
fi
39+
40+
- name: Close consolidated PRs
41+
if: steps.check_consolidation.outputs.is_consolidation == 'true'
42+
uses: actions/github-script@v7
43+
with:
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
script: |
46+
const owner = context.repo.owner;
47+
const repo = context.repo.repo;
48+
49+
// List of PR numbers to close (from consolidation)
50+
const prsToClose = [1, 7, 8, 10, 12, 14, 15];
51+
52+
// Add comment and close each PR
53+
for (const prNumber of prsToClose) {
54+
try {
55+
// Check if PR exists and is open
56+
const { data: pr } = await github.rest.pulls.get({
57+
owner,
58+
repo,
59+
pull_number: prNumber
60+
});
61+
62+
if (pr.state === 'open') {
63+
// Add comment explaining consolidation
64+
await github.rest.issues.createComment({
65+
owner,
66+
repo,
67+
issue_number: prNumber,
68+
body: `This PR has been consolidated into #${{ github.event.pull_request.number }} and merged to master.\n\nAll changes from this PR are included in the consolidated merge. Closing as completed.`
69+
});
70+
71+
// Close the PR
72+
await github.rest.pulls.update({
73+
owner,
74+
repo,
75+
pull_number: prNumber,
76+
state: 'closed'
77+
});
78+
79+
console.log(`✅ Closed PR #${prNumber}`);
80+
} else {
81+
console.log(`ℹ️ PR #${prNumber} is already ${pr.state}`);
82+
}
83+
} catch (error) {
84+
console.log(`⚠️ Could not process PR #${prNumber}: ${error.message}`);
85+
}
86+
}
87+
88+
- name: Delete consolidated branches
89+
if: steps.check_consolidation.outputs.is_consolidation == 'true'
90+
uses: actions/github-script@v7
91+
with:
92+
github-token: ${{ secrets.GITHUB_TOKEN }}
93+
script: |
94+
const owner = context.repo.owner;
95+
const repo = context.repo.repo;
96+
97+
// List of branches to delete (from consolidation)
98+
const branchesToDelete = [
99+
'refactor-cleanup',
100+
'phase1-refactor-pyscript-deps',
101+
'fix/eslint-errors',
102+
'snyk-upgrade-element-plus-2.9.1',
103+
'snyk-upgrade-element-plus-2.9.5',
104+
'snyk-upgrade-element-plus-2.10.5'
105+
];
106+
107+
for (const branch of branchesToDelete) {
108+
try {
109+
await github.rest.git.deleteRef({
110+
owner,
111+
repo,
112+
ref: `heads/${branch}`
113+
});
114+
console.log(`✅ Deleted branch: ${branch}`);
115+
} catch (error) {
116+
console.log(`⚠️ Could not delete branch ${branch}: ${error.message}`);
117+
}
118+
}
119+
120+
- name: Create cleanup summary
121+
if: steps.check_consolidation.outputs.is_consolidation == 'true'
122+
uses: actions/github-script@v7
123+
with:
124+
github-token: ${{ secrets.GITHUB_TOKEN }}
125+
script: |
126+
const owner = context.repo.owner;
127+
const repo = context.repo.repo;
128+
129+
// Add comment to the merged PR summarizing cleanup
130+
await github.rest.issues.createComment({
131+
owner,
132+
repo,
133+
issue_number: context.issue.number,
134+
body: `## 🧹 Post-Merge Cleanup Complete\n\n` +
135+
`✅ Consolidated PRs have been closed\n` +
136+
`✅ Obsolete branches have been deleted\n\n` +
137+
`The repository is now clean and ready for future development.`
138+
});

.huskyrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"hooks": {
3+
"pre-commit": "npm run format:check && npm run lint -- --no-fix",
4+
"pre-push": "npm run type-check && npm run build"
5+
}
6+
}

0 commit comments

Comments
 (0)