Skip to content

Commit d575424

Browse files
authored
feat: self healing dependabot updates (#4292)
* feat: self healing dependabot updates for prettier and stylelint updates * Create 99-self-healing-dependabot-updates.yml
1 parent 8afc75c commit d575424

File tree

9 files changed

+474
-336
lines changed

9 files changed

+474
-336
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
name: "Auto commit and merge changes"
3+
description: "Creates a new branch and commits current changes and merges it afterwards to retrigger pipeline"
4+
inputs:
5+
branch-name:
6+
description: "The new branch name to commit to"
7+
required: true
8+
commit-message:
9+
description: "The message you want to commit"
10+
required: true
11+
commit-files:
12+
description: "The files which should be commited with `git add xxx`"
13+
required: true
14+
15+
runs:
16+
using: "composite"
17+
steps:
18+
# https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow
19+
- name: 🧬 Generate a token
20+
id: generate-token
21+
uses: actions/create-github-app-token@v2
22+
with:
23+
app-id: ${{ vars.AUTO_MERGE_APP_ID }}
24+
private-key: ${{ secrets.AUTO_MERGE_PRIVATE_KEY }}
25+
26+
- name: 🏗️ Create new branch and commit changes
27+
shell: bash
28+
env:
29+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
NEW_PR_BRANCH: ${{ inputs.branch-name }}
31+
COMMIT_MESSAGE: ${{ inputs.commit-message }}
32+
COMMIT_FILES: ${{ inputs.commit-files }}
33+
run: |
34+
git config --global user.name "github-actions[bot]"
35+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
36+
37+
git checkout -b "$NEW_PR_BRANCH"
38+
git add $COMMIT_FILES
39+
40+
# We can't use semantic commits here because of the if statement in the workflow
41+
git commit --no-verify -m "$COMMIT_MESSAGE"
42+
git push -f origin "$NEW_PR_BRANCH"
43+
44+
- name: 🪗 Create Pull Request
45+
shell: bash
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
COMMIT_MESSAGE: ${{ inputs.commit-message }}
49+
NEW_PR_BRANCH: ${{ inputs.branch-name }}
50+
BASE_BRANCH: ${{ github.head_ref }}
51+
run: |
52+
gh pr create --base "$BASE_BRANCH" --head "$NEW_PR_BRANCH" --title "Automated PR: $COMMIT_MESSAGE" --body "This PR was created automatically by a GitHub Action."
53+
54+
- name: 🤖 Squash the PR
55+
shell: bash
56+
run: gh pr merge --squash "$NEW_PR_BRANCH"
57+
env:
58+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
59+
NEW_PR_BRANCH: ${{ inputs.branch-name }}

.github/actions/npm-cache/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ runs:
2424
with:
2525
node-version: ${{ inputs.nodeVersion }}
2626

27-
- name: Display node and npm version
27+
- name: 🖼️ Display node and npm version
2828
shell: bash
2929
run: |
3030
node --version

.github/workflows/02-e2e-regenerated-snapshots-commit.yml

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
permissions:
2929
contents: write
3030
pull-requests: write
31-
env:
32-
NEW_PR_BRANCH: "${{ github.head_ref }}-auto"
3331
steps:
3432
- name: ⏬ Checkout repo
3533
uses: actions/checkout@v4
@@ -66,35 +64,9 @@ jobs:
6664
name: snapshots-showcases
6765
path: ./__snapshots__/
6866

69-
# https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow
70-
- name: 🧬 Generate a token
71-
id: generate-token
72-
uses: actions/create-github-app-token@v2
67+
- name: 🚘 Auto commit
68+
uses: ./.github/actions/auto-commit
7369
with:
74-
app-id: ${{ vars.AUTO_MERGE_APP_ID }}
75-
private-key: ${{ secrets.AUTO_MERGE_PRIVATE_KEY }}
76-
77-
- name: 🏗️ Create new branch and commit changes
78-
env:
79-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80-
run: |
81-
git config --global user.name "github-actions[bot]"
82-
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
83-
84-
git checkout -b "$NEW_PR_BRANCH"
85-
git add __snapshots__/*
86-
87-
# We can't use semantic commits here because of the if statement in the workflow
88-
git commit --no-verify -m "auto update snapshots"
89-
git push -f origin "$NEW_PR_BRANCH"
90-
91-
- name: 🪗 Create Pull Request
92-
env:
93-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94-
run: |
95-
gh pr create --base ${{ github.head_ref }} --head "$NEW_PR_BRANCH" --title "Automated PR: Auto update snapshots" --body "This PR was created automatically by a GitHub Action."
96-
97-
- name: 🤖 Squash the PR
98-
run: gh pr merge --squash "$NEW_PR_BRANCH"
99-
env:
100-
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
70+
branch-name: "${{ github.head_ref }}-auto"
71+
commit-message: "auto update snapshots"
72+
commit-files: "__snapshots__/*"
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Auto-Format with Stylelint and Prettier
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
format:
8+
name: 🆙 Auto-Format
9+
if: ${{ github.actor == 'dependabot[bot]' }}
10+
runs-on: ubuntu-24.04 # Use Ubuntu 24.04 explicitly
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
steps:
15+
- name: ⏬ Checkout code
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.head_ref }}
19+
20+
- name: 🔍 Check if Stylelint or Prettier update PR
21+
id: check_pr
22+
run: |
23+
echo "PR title: ${{ github.event.pull_request.title }}"
24+
if [[ "${{ github.event.pull_request.title }}" =~ "bump stylelint from" ]]; then
25+
echo "Stylelint update detected."
26+
echo "stylelint_update=true" >> $GITHUB_ENV
27+
elif [[ "${{ github.event.pull_request.title }}" =~ "bump prettier from" ]]; then
28+
echo "Prettier update detected."
29+
echo "prettier_update=true" >> $GITHUB_ENV
30+
else
31+
echo "No Stylelint or prettier updates detected."
32+
fi
33+
34+
- name: 🆙 Set up Node.js
35+
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version-file: ".nvmrc"
39+
40+
- name: ⏬ Install dependencies
41+
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
42+
run: |
43+
npm ci
44+
45+
- name: 🏃 Run Stylelint to format the code
46+
if: env.stylelint_update == 'true'
47+
run: |
48+
npm run lint:stylelint --fix
49+
50+
- name: 🏃 Run Prettier to format the code
51+
if: env.prettier_update == 'true'
52+
run: |
53+
npm run fmt
54+
55+
- name: 🚘 Auto commit
56+
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
57+
uses: ./.github/actions/auto-commit
58+
with:
59+
branch-name: "${{ github.head_ref }}-auto"
60+
commit-message: "auto format code"
61+
commit-files: "."

.github/workflows/pull-request.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
dependabot:
1616
uses: ./.github/workflows/99-auto-merge.yml
1717

18+
self-healing-dependabot-updates:
19+
uses: ./.github/workflows/99-self-healing-dependabot-updates.yml
20+
secrets: inherit
21+
1822
codeql:
1923
uses: ./.github/workflows/99-codeql-analysis.yml
2024

docs/research/table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Design System | Component | Comment |
66
| --------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
| [Atlassian Design System](https://bitbucket.org/atlassian/atlaskit/src/master/) | [table](https://atlassian.design/components/table) / [table-tree](https://atlassian.design/components/table-tree/) | _Table_: interactive data table with built-in pagination, sorting, and column reordering.<br />_Table Tree_: hierarchical table with expandable, nested rows. |
8-
| [Bootstrap](https://github.com/twbs/bootstrap) | [table](https://getbootstrap.com/docs/4.3/content/tables/) | Static tables styled via CSS classes (striped rows, borders). Responsive behavior via `.table-responsive wrapper` for horizontal scrolling. No built-in interactivity (sorting, etc. requires custom scripts). |
8+
| [Bootstrap](https://github.com/twbs/bootstrap) | [table](https://getbootstrap.com/docs/4.3/content/tables/) | Static tables styled via CSS classes (striped rows, borders). Responsive behavior via `.table-responsive wrapper` for horizontal scrolling. No built-in interactivity (sorting, etc. requires custom scripts). |
99
| [GitHub Primer](https://github.com/primer/css) | [data-table](https://primer.style/product/components/data-table/) | React component with column definitions and custom cells. Advanced features like sorting, selectable rows, sticky headers, etc. Currently no built-in pagination. |
1010
| [GitLab Pajamas](https://gitlab.com/gitlab-org/gitlab-services/design.gitlab.com) | [table](https://design.gitlab.com/components/table) | Table with Basic, Striped, Condensed variants, sortable columns, pagination, responsive scroll. Underlying implementation in Vue/Rails (`<gl-table-lite>`) using Bootstrap-Vue. |
1111
| [HP Enterprise Grommet](https://github.com/grommet/grommet) | [table](https://v2.grommet.io/table) | Offers table for dynamic data: sorting, multi-select (onSelect, allowSelectAll), pagination/infinite scroll (onMore), grouping (groupBy), icons/buttons in cells, styling options. |

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
"clean": "git clean -dfx --exclude=.env",
3131
"commit:updated-snapshots": "git diff --name-only --diff-filter=M | xargs git add && git commit -m 'test: updated snapshots'",
3232
"dev": "npm run dev --workspace=scripts",
33+
"fmt": "prettier . --write",
3334
"generate:component": "npm run generate:component --workspace=@db-ux/core-components",
3435
"lint": "npm-run-all -p lint:*",
3536
"lint:jscpd": "jscpd . --exitCode 1 --config .config/.jscpd.json",
3637
"lint:markdownlint": "markdownlint -c .config/.markdown-lint.yml **/*.md",
37-
"lint:stylelint": "stylelint **/*.scss",
38+
"lint:stylelint": "stylelint **/*.{css,scss}",
3839
"lint:xo": "cross-env TIMING=1 NODE_OPTIONS=\"--max-old-space-size=4096\" xo",
3940
"prepare": "husky",
4041
"regenerate:screenshots": "npm run build && npm run build --workspace=react-showcase && docker-compose -f ./e2e/docker-compose.regenerate.yml up",

0 commit comments

Comments
 (0)