Skip to content

Commit 34d3a69

Browse files
committed
feat: create weekly maintenance CI
1 parent f447761 commit 34d3a69

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Weekly Maintenance
2+
3+
on:
4+
schedule:
5+
- cron: "0 22 * * 0"
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
weekly-maintenance:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
ref: main
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: "8.2"
26+
coverage: none
27+
tools: composer
28+
29+
- name: Install dependencies
30+
run: composer install --prefer-dist --no-progress --no-interaction
31+
32+
- name: Setup Mago
33+
uses: nhedger/setup-mago@v1
34+
35+
- name: Run Mago analyze
36+
run: composer mago:analyze
37+
38+
- name: Run Rector maintenance config
39+
run: composer rector:maintenance
40+
41+
- name: Check for changes
42+
id: changes
43+
run: |
44+
if [[ -n "$(git status --porcelain)" ]]; then
45+
echo "changed=true" >> "$GITHUB_OUTPUT"
46+
else
47+
echo "changed=false" >> "$GITHUB_OUTPUT"
48+
fi
49+
50+
- name: Generate branch name
51+
if: steps.changes.outputs.changed == 'true'
52+
id: branch
53+
run: |
54+
echo "name=chore/weekly-maintenance-$(date +'%Y%m%d')" >> "$GITHUB_OUTPUT"
55+
56+
- name: Commit changes
57+
if: steps.changes.outputs.changed == 'true'
58+
run: |
59+
git config user.name "github-actions[bot]"
60+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
61+
git checkout -b "${{ steps.branch.outputs.name }}"
62+
git add .
63+
git commit -m "chore: apply weekly maintenance fixes"
64+
65+
- name: Push branch
66+
if: steps.changes.outputs.changed == 'true'
67+
run: |
68+
git push origin "${{ steps.branch.outputs.name }}"
69+
70+
- name: Create pull request
71+
if: steps.changes.outputs.changed == 'true'
72+
uses: peter-evans/create-pull-request@v7
73+
with:
74+
branch: ${{ steps.branch.outputs.name }}
75+
title: "chore: weekly maintenance fixes"
76+
body: |
77+
## Description
78+
This PR contains weekly automated maintenance updates.
79+
80+
### Included
81+
- Mago analysis executed
82+
- Rector safe maintenance rules applied
83+
84+
## Notes
85+
Please review the changes carefully before merging.
86+
commit-message: "chore: apply weekly maintenance fixes"
87+
base: main
88+
delete-branch: false

0 commit comments

Comments
 (0)