-
Notifications
You must be signed in to change notification settings - Fork 10
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
mfranzke
wants to merge
17
commits into
main
Choose a base branch
from
feat-self-healing-dependabot-updates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
dc81a5a
feat: self healing dependabot updates
mfranzke 6016a8e
Create 99-self-healing-dependabot-updates.yml
mfranzke b7d9cc2
Merge branch 'main' into feat-self-healing-dependabot-updates
mfranzke 2e60968
Update 99-self-healing-dependabot-updates.yml
mfranzke 16af60f
Update 99-self-healing-dependabot-updates.yml
mfranzke 23666c7
Update 99-self-healing-dependabot-updates.yml
mfranzke 9d52c9e
Update package.json
mfranzke f0d4193
Merge branch 'main' into feat-self-healing-dependabot-updates
mfranzke 157d49f
Merge branch 'main' into feat-self-healing-dependabot-updates
mfranzke 3fae29d
Update 99-self-healing-dependabot-updates.yml
mfranzke 7db5853
Update 99-self-healing-dependabot-updates.yml
mfranzke ffa5d87
Update pull-request.yml
mfranzke 84c207e
Update .github/workflows/99-self-healing-dependabot-updates.yml
mfranzke 85e5d49
Merge branch 'main' into feat-self-healing-dependabot-updates
nmerget 879d5a5
refactor: moved auto-commit to own composite action
nmerget 9807ba6
chore: run fmt
nmerget 7988041
Potential fix for code scanning alert no. 9: Expression injection in …
nmerget File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
mfranzke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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: "." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 ?