Skip to content

Commit 1133bc5

Browse files
authored
refactor(cicd): optimize self-healing (#4659)
* refactor(cicd): optimize self-healing * refactor: further optimizations * Update action.yml
1 parent 3089ba5 commit 1133bc5

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

.github/actions/auto-commit/action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ inputs:
2424
runs:
2525
using: "composite"
2626
steps:
27+
- name: 🚦 Check for changes before committing
28+
id: check_changes
29+
shell: bash
30+
run: |
31+
if [[ -z "$(git status --porcelain)" ]]; then
32+
echo "No changes to commit. Skipping auto-commit step."
33+
echo "changes_detected=false" >> $GITHUB_ENV
34+
else
35+
echo "Changes detected. Proceeding with creating a new branch and commit changes."
36+
echo "changes_detected=true" >> $GITHUB_ENV
37+
fi
38+
2739
- name: 🏗️ Create new branch and commit changes
40+
if: env.changes_detected == 'true'
2841
shell: bash
2942
env:
3043
GH_TOKEN: ${{ inputs.gh-token }}
@@ -44,6 +57,7 @@ runs:
4457
git push --force origin "$NEW_PR_BRANCH"
4558
4659
- name: 🪗 Create Pull Request
60+
if: env.changes_detected == 'true'
4761
shell: bash
4862
env:
4963
GH_TOKEN: ${{ inputs.gh-token }}
@@ -62,6 +76,7 @@ runs:
6276
private-key: ${{ inputs.auto-merge-private-key }}
6377

6478
- name: 🤖 Squash the PR
79+
if: env.changes_detected == 'true'
6580
shell: bash
6681
run: gh pr merge --squash "$NEW_PR_BRANCH"
6782
env:

.github/workflows/99-self-healing-dependabot-updates.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ jobs:
2121
id: check_pr
2222
run: |
2323
echo "PR title: ${{ github.event.pull_request.title }}"
24-
if [[ "${{ github.event.pull_request.title }}" =~ "bump stylelint from" ]]; then
24+
if [[ "${{ github.event.pull_request.title }}" =~ "bump stylelint from" ]] || [[ "${{ github.event.pull_request.title }}" =~ "bump the stylelint group with" ]]; then
2525
echo "Stylelint update detected."
2626
echo "stylelint_update=true" >> $GITHUB_ENV
27-
elif [[ "${{ github.event.pull_request.title }}" =~ "bump prettier from" ]]; then
27+
elif [[ "${{ github.event.pull_request.title }}" =~ "bump prettier from" ]] || [[ "${{ github.event.pull_request.title }}" =~ "bump the prettier group with" ]]; then
2828
echo "Prettier update detected."
2929
echo "prettier_update=true" >> $GITHUB_ENV
3030
else
31-
echo "No Stylelint or prettier updates detected."
31+
echo "No Stylelint or Prettier updates detected."
3232
fi
3333
3434
- name: 🆙 Set up Node.js
@@ -53,18 +53,8 @@ jobs:
5353
run: |
5454
npm run codestyle
5555
56-
- name: 🚦 Check for changes before committing
57-
id: check_changes
58-
run: |
59-
if [[ -z "$(git status --porcelain)" ]]; then
60-
echo "No changes to commit. Skipping auto-commit step."
61-
echo "changes_detected=false" >> $GITHUB_ENV
62-
else
63-
echo "Changes detected. Proceeding to auto-commit step."
64-
echo "changes_detected=true" >> $GITHUB_ENV
65-
6656
- name: 🚘 Auto commit
67-
if: steps.check_changes.outputs.changes_detected == 'true' && (env.stylelint_update == 'true' || env.prettier_update == 'true')
57+
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
6858
uses: ./.github/actions/auto-commit
6959
with:
7060
branch-name: "${{ github.head_ref }}-auto"

0 commit comments

Comments
 (0)