-
Notifications
You must be signed in to change notification settings - Fork 49
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(github-actions): implement GitHub Action for creating a PR from local changes #738
feat(github-actions): implement GitHub Action for creating a PR from local changes #738
Conversation
d73d5bb
to
6368656
Compare
6368656
to
fae2dcd
Compare
// particular set of changes. It is not 100% accurate (and could result in both false | ||
// positives and false negatives), but should be good enough for our purposes. | ||
const branchPrefix = core.getInput('branch-prefix', {required: true}); | ||
const branchName = `${branchPrefix}-${hashFiles(touchedFiles)}`; |
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.
Why not derive the branch name using the commit sha?
${branchPrefix}-${git.run(['rev-parse', 'HEAD'])}
We could then rely on Git to create something that is even more likely to be unique.
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.
This is not just about being unique, but about uniquely identifying a set of changes (regardless of other changes that might have happened to the repo).
Imagine that we use this action to modify file foo.txt
. I can have two separate SHAs that both apply the same change to file foo.txt
but are different because their parent SHA is different (due to the unrelated file bar.txt
being modified between the two). In such a case, we want to recognize that both commits apply the same change, even though their SHAs are different.
Does that make sense?
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.
Yeah, that makes sense. Will this hold for an action that doesn't always change all of the same files though? For instance if you have an action that updates all of the generated files, but some of them are unchanged.
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 current hashing looks at the files modified by the action run and their content. If there are two different runs that result in the same files being touched and the contents of those touched files are the same on both runs, then the two runs will be considered the same.
If you have two runs that result in a different set of files being touched (or if the contents of the touched files has changed between the two runs), then they will be considered different.
This can result in "misses" (i.e. two runs that should be identified as the same being considered different), but that is not a big problem: It just means that we might get two PRs that do the same thing.
…local changes Implement a new GitHub Action, `create-pr-for-changes` that can check for changes in the working copy and create a pull request. It can skip creating a pull request if there are no local changes or if a pull request already exists for the same changes and branches (based on some heuristic - see `github-actions/create-pr-for-changes/lib/main.ts` for details). This action can be useful for periodically updating checked-in files that are auto-generated based on data from external sources (such as events stored in a database).
d2f9d47
to
17d093e
Compare
…R from local changes
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.
LGTM
Just the one thing to resolve and be sure about.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Implement a new GitHub Action,
create-pr-for-changes
that can check for changes in the working copy and create a pull request. It can skip creating a pull request if there are no local changes or if a pull request already exists for the same changes and branches (based on some heuristic - seegithub-actions/create-pr-for-changes/lib/main.ts
for details).This action can be useful for periodically updating checked-in files that are auto-generated based on data from external sources (such as events stored in a database).
FYI, I have tested the new action with angular/angular#45588 (at commit c3e545f) with a slight modification: using the GitHub Action provided token instead of an
angular-robot-key
, since the Angular Robot is not installed on my fork.Here are a couple of runs: