-
Notifications
You must be signed in to change notification settings - Fork 236
chore(ci): update dependencies without force push COMPASS-9939 #7445
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
base: main
Are you sure you want to change the base?
Conversation
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ env.UPDATE_BRANCH_NAME }} | ||
path: existing-branch-checkout |
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.
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?
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.
Good catch. Perhaps we should just add it to the .gitignore
?
Dispatched this manually on "eslint", which at the time of running already had a PR open and it did seem to skip the |
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.
Pull Request Overview
This PR improves the CI dependency update workflow to avoid unnecessary force pushes by checking for existing branches and comparing package-lock.json files before creating or updating pull requests.
- Adds branch existence checking to prevent overwriting manual commits on update branches
- Implements sparse checkout of existing branches to compare package-lock.json changes
- Makes PR creation conditional based on branch existence and actual file differences
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- name: Create Pull Request | ||
if: steps.check-branch-exists.outputs.branch_exists == 'false' || hashFiles('package-lock.json') != hashFiles('existing-branch-checkout/package-lock.json') |
Copilot
AI
Oct 13, 2025
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.
The hashFiles()
function will return an empty string when the file doesn't exist. If the existing branch checkout fails or the sparse checkout doesn't work as expected, hashFiles('existing-branch-checkout/package-lock.json')
could return an empty string, making the comparison unreliable. Consider adding a check to ensure the existing branch checkout was successful before comparing hashes.
- name: Create Pull Request | |
if: steps.check-branch-exists.outputs.branch_exists == 'false' || hashFiles('package-lock.json') != hashFiles('existing-branch-checkout/package-lock.json') | |
- name: Check if existing branch lockfile exists | |
if: steps.check-branch-exists.outputs.branch_exists == 'true' | |
id: check-existing-lockfile | |
run: | | |
if [ -f "existing-branch-checkout/package-lock.json" ]; then | |
echo "exists=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "exists=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create Pull Request | |
if: steps.check-branch-exists.outputs.branch_exists == 'false' || (steps.check-branch-exists.outputs.branch_exists == 'true' && steps.check-existing-lockfile.outputs.exists == 'true' && hashFiles('package-lock.json') != hashFiles('existing-branch-checkout/package-lock.json')) || (steps.check-branch-exists.outputs.branch_exists == 'true' && steps.check-existing-lockfile.outputs.exists == 'false') |
Copilot uses AI. Check for mistakes.
874b277
to
7c5c5bf
Compare
Description
Merging this PR will:
Checklist
Motivation and Context
See peter-evans/create-pull-request#3977 and section in the action's README.md for a bit more context on the lack of this feature in the "create-pull-request" action.
Open Questions
Dependents
Types of changes