Skip to content
Merged
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
28 changes: 27 additions & 1 deletion .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
name: Update ${{ matrix.group_name }} to latest
runs-on: ubuntu-latest
needs: configure_matrix
env:
UPDATE_BRANCH_NAME: ci/update-${{ matrix.group_name }}
strategy:
matrix:
group_name: ${{ fromJSON(needs.configure_matrix.outputs.group_name) }}
Expand Down Expand Up @@ -77,12 +79,36 @@ jobs:
- name: Run "update dependencies" script
run: npx compass-scripts update-dependencies preset-${{ matrix.group_name }}

# Conditionally performing a sparse checkout of the existing branch to compare changes
# and avoid the "create-pull-request" action force-pushing when changes aren't necessary.
# This also allows us pushing commits to the update branch to fix any breaking changes
# without risking these commits being overwritten by the action.
- name: Check existence of an existing branch
id: check-branch-exists
run: |
if git ls-remote --exit-code --heads origin ${{ env.UPDATE_BRANCH_NAME }}; then
echo "branch_exists=true" >> "$GITHUB_OUTPUT"
else
echo "branch_exists=false" >> "$GITHUB_OUTPUT"
fi

- name: Checkout existing branch
if: steps.check-branch-exists.outputs.branch_exists == 'true'
uses: actions/checkout@v4
with:
ref: ${{ env.UPDATE_BRANCH_NAME }}
path: existing-branch-checkout
Copy link
Collaborator

@gribnoysup gribnoysup Oct 13, 2025

Choose a reason for hiding this comment

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

A bit hard to validate until we actually manage to make this task update an exiting PR, but just reading through this change seems like this checked out file will continue to be there if the PR is being created updated and I think the create-pull-request will commit it with other files. We probably want to clean it up before this happens?

Copy link
Contributor Author

@kraenhansen kraenhansen Oct 13, 2025

Choose a reason for hiding this comment

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

Good catch. Perhaps we should just add it to the .gitignore?

sparse-checkout: |
package-lock.json
sparse-checkout-cone-mode: false

- name: Create Pull Request
if: steps.check-branch-exists.outputs.branch_exists == 'false' || hashFiles('package-lock.json') != hashFiles('existing-branch-checkout/package-lock.json')
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5
with:
token: ${{ steps.app-token.outputs.token }}
commit-message: 'chore(deps): update ${{ matrix.group_name }} to latest'
branch: ci/update-${{ matrix.group_name }}
branch: ${{ env.UPDATE_BRANCH_NAME }}
title: 'chore(deps): update ${{ matrix.group_name }} to latest'
labels: |
no-title-validation
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ config/*/.npmrc
.sbom
.logs
.evergreen/logs

# The update-dependencies workflow does a sparse checkout
# and we don't want to include these files in the PRs it creates.
existing-branch-checkout/