Skip to content
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

feat: add a workflow that cleans up after dependabot #1776

Merged
merged 3 commits into from
Jul 14, 2023
Merged
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/workflows/dependabot_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow runs `lerna bootstrap` after dependabot updates a package-lock file.
# Without it, package-locks become cluttered with incorrect dependencies that
# normally would be removed by lerna. It wouldn't be necessary if we weren't using
# lerna bootstrap.

name: Clean up after dependabot

# Triggered when a PR is (re)opened or synchronized
on: pull_request

permissions:
pull-requests: write # This action adds commits to PRs

jobs:
update:
runs-on: ubuntu-latest
# Only run on dependabot PRs
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Check out the dependabot PR so commits are added there
- name: Checkout PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.pull_request.number }}

# This uses a reverse-engineered email for the github actions bot. See
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
- name: Git identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '<41898282+github-actions[bot]@users.noreply.github.com'

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20

- name: Lerna bootstrap
run: |
npm run boot
cd examples && npm run boot

# If any package-locks were updated by lerna bootstrap, commit them
# Using `[dependabot skip]` in the commit message allows dependabot
maribethb marked this conversation as resolved.
Show resolved Hide resolved
# to continue making changes to this PR after it is updated
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/managing-pull-requests-for-dependency-updates#allowing-dependabot-to-rebase-and-force-push-over-extra-commits
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ $(git status | grep '.package-lock.json') ]]; then
git commit -am "chore: update package-locks [dependabot skip]"
git push
else
echo "No changes detected"
fi
Loading