Skip to content

feat: self healing dependabot updates #4292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/actions/auto-commit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: "Auto commit and merge changes"
description: "Creates a new branch and commits current changes and merges it afterwards to retrigger pipeline"
inputs:
branch-name:
description: "The new branch name to commit to"
required: true
commit-message:
description: "The message you want to commit"
required: true
commit-files:
description: "The files which should be commited with `git add xxx`"
required: true

runs:
using: "composite"
steps:
# 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
- name: 🧬 Generate a token
id: generate-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.AUTO_MERGE_APP_ID }}
private-key: ${{ secrets.AUTO_MERGE_PRIVATE_KEY }}

- name: 🏗️ Create new branch and commit changes
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEW_PR_BRANCH: ${{ inputs.branch-name }}
COMMIT_MESSAGE: ${{ inputs.commit-message }}
COMMIT_FILES: ${{ inputs.commit-files }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

git checkout -b "$NEW_PR_BRANCH"
git add $COMMIT_FILES

# We can't use semantic commits here because of the if statement in the workflow
git commit --no-verify -m "$COMMIT_MESSAGE"
git push -f origin "$NEW_PR_BRANCH"

- name: 🪗 Create Pull Request
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_MESSAGE: ${{ inputs.commit-message }}
NEW_PR_BRANCH: ${{ inputs.branch-name }}
run: |
BASE_BRANCH="${{ github.head_ref }}"
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."

- name: 🤖 Squash the PR
shell: bash
run: gh pr merge --squash "$NEW_PR_BRANCH"
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
NEW_PR_BRANCH: ${{ inputs.branch-name }}
2 changes: 1 addition & 1 deletion .github/actions/npm-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ runs:
with:
node-version: ${{ inputs.nodeVersion }}

- name: Display node and npm version
- name: 🖼️ Display node and npm version
shell: bash
run: |
node --version
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/00-init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
ASSET_INIT_VECTOR: ${{ secrets.ASSET_INIT_VECTOR }}
ASSET_PASSWORD: ${{ secrets.ASSET_PASSWORD }}

# - name: 🚮 Dump GitHub context for debugging
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
- name: 🚮 Dump GitHub context for debugging
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mfranzke I would keep this always inside the pipeline. We don't like to uncommet/comment it every time we debug.

Copy link
Collaborator Author

@mfranzke mfranzke Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a comment by GitHub Copilot that sharing the full content of this variable might leak internal information. As the logs are public, this might be a valid aspect. Is there a non-public-space we could pass the output to ?

env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- name: 💀 Killing me softly
uses: ./.github/actions/cancel-workflow
Expand Down
38 changes: 5 additions & 33 deletions .github/workflows/02-e2e-regenerated-snapshots-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ jobs:
permissions:
contents: write
pull-requests: write
env:
NEW_PR_BRANCH: "${{ github.head_ref }}-auto"
steps:
- name: ⏬ Checkout repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -66,35 +64,9 @@ jobs:
name: snapshots-showcases
path: ./__snapshots__/

# 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
- name: 🧬 Generate a token
id: generate-token
uses: actions/create-github-app-token@v2
- name: 🚘 Auto commit
uses: ./.github/actions/auto-commit
with:
app-id: ${{ vars.AUTO_MERGE_APP_ID }}
private-key: ${{ secrets.AUTO_MERGE_PRIVATE_KEY }}

- name: 🏗️ Create new branch and commit changes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

git checkout -b "$NEW_PR_BRANCH"
git add __snapshots__/*

# We can't use semantic commits here because of the if statement in the workflow
git commit --no-verify -m "auto update snapshots"
git push -f origin "$NEW_PR_BRANCH"

- name: 🪗 Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
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."

- name: 🤖 Squash the PR
run: gh pr merge --squash "$NEW_PR_BRANCH"
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
branch-name: "${{ github.head_ref }}-auto"
commit-message: "auto update snapshots"
commit-files: "__snapshots__/*"
61 changes: 61 additions & 0 deletions .github/workflows/99-self-healing-dependabot-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Auto-Format with Stylelint and Prettier

on:
workflow_call:

jobs:
format:
name: 🆙 Auto-Format
if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-24.04 # Use Ubuntu 24.04 explicitly
permissions:
contents: write
pull-requests: write
steps:
- name: ⏬ Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: 🔍 Check if Stylelint or Prettier update PR
id: check_pr
run: |
echo "PR title: ${{ github.event.pull_request.title }}"
if [[ "${{ github.event.pull_request.title }}" =~ "bump stylelint from" ]]; then
echo "Stylelint update detected."
echo "stylelint_update=true" >> $GITHUB_ENV
elif [[ "${{ github.event.pull_request.title }}" =~ "bump prettier from" ]]; then
echo "Prettier update detected."
echo "prettier_update=true" >> $GITHUB_ENV
else
echo "No Stylelint or prettier updates detected."
fi

- name: 🆙 Set up Node.js
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"

- name: ⏬ Install dependencies
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
run: |
npm ci

- name: 🏃 Run Stylelint to format the code
if: env.stylelint_update == 'true'
run: |
npm run lint:stylelint --fix

- name: 🏃 Run Prettier to format the code
if: env.prettier_update == 'true'
run: |
npm run fmt

- name: 🚘 Auto commit
if: env.stylelint_update == 'true' || env.prettier_update == 'true'
uses: ./.github/actions/auto-commit
with:
branch-name: "${{ github.head_ref }}-auto"
commit-message: "auto format code"
commit-files: "."
4 changes: 4 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
dependabot:
uses: ./.github/workflows/99-auto-merge.yml

self-healing-dependabot-updates:
uses: ./.github/workflows/99-self-healing-dependabot-updates.yml
secrets: inherit

codeql:
uses: ./.github/workflows/99-codeql-analysis.yml

Expand Down
2 changes: 1 addition & 1 deletion docs/research/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| Design System | Component | Comment |
| --------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [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. |
| [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). |
| [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). |
| [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. |
| [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. |
| [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. |
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
"clean": "git clean -dfx --exclude=.env",
"commit:updated-snapshots": "git diff --name-only --diff-filter=M | xargs git add && git commit -m 'test: updated snapshots'",
"dev": "npm run dev --workspace=scripts",
"fmt": "prettier . --write",
"generate:component": "npm run generate:component --workspace=@db-ux/core-components",
"lint": "npm-run-all -p lint:*",
"lint:jscpd": "jscpd . --exitCode 1 --config .config/.jscpd.json",
"lint:markdownlint": "markdownlint -c .config/.markdown-lint.yml **/*.md",
"lint:stylelint": "stylelint **/*.scss",
"lint:stylelint": "stylelint **/*.{css,scss}",
"lint:xo": "cross-env TIMING=1 NODE_OPTIONS=\"--max-old-space-size=4096\" xo",
"prepare": "husky",
"regenerate:screenshots": "npm run build && npm run build --workspace=react-showcase && docker-compose -f ./e2e/docker-compose.regenerate.yml up",
Expand Down
Loading