-
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
21 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 eb913c3
Merge remote-tracking branch 'origin/main' into feat-self-healing-dep…
nmerget e5a9ee3
Merge branch 'main' into feat-self-healing-dependabot-updates
nmerget 4cd1a54
Potential fix for code scanning alert no. 10: Expression injection in…
nmerget d94f654
Merge branch 'main' into feat-self-healing-dependabot-updates
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,91 @@ | ||
name: Auto-Format with Stylelint and Prettier on PR for "self-healing" PRs | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
format: | ||
if: ${{ github.actor == 'dependabot[bot]' }} | ||
runs-on: ubuntu-24.04 # Use Ubuntu 24.04 explicitly | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
env: | ||
NEW_PR_BRANCH: "${{ github.head_ref }}-auto" | ||
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: | | ||
npx --no prettier . --write | ||
|
||
# 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 | ||
nmerget marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: 🧬 Generate a token | ||
if: env.stylelint_update == 'true' || env.prettier_update == 'true' | ||
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 | ||
if: env.stylelint_update == 'true' || env.prettier_update == 'true' | ||
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 . | ||
|
||
# We can't use semantic commits here because of the if statement in the workflow | ||
git commit --no-verify --all -m "auto format code" || echo "No changes to commit" | ||
git push -f origin "$NEW_PR_BRANCH" | ||
|
||
- name: 🪗 Create Pull Request | ||
if: env.stylelint_update == 'true' || env.prettier_update == 'true' | ||
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 | ||
if: env.stylelint_update == 'true' || env.prettier_update == 'true' | ||
run: gh pr merge --squash "$NEW_PR_BRANCH" | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} |
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.
Uh oh!
There was an error while loading. Please reload this page.