chinthakagodawita / autoupdate Goto Github PK
View Code? Open in Web Editor NEWA GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
License: MIT License
A GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
License: MIT License
Would you be open to a PR that adds the following option?
EXCLUDE_DRAFTS
: When "true"
, merge/update operations are not performed on draft pull requests. Defaults to "false"
.Hi @chinthakagodawita,
I have a follow-up question to #19 it seems that after trying to work forked PR which is very common in opensource the bot just dies, right? so even there are other PR it could resolve it just stop with reaching the first difficult PR...
So would it be possible to change this error as a warning (eventually add an argument such as "continue-if-fails") and continue with other PRs?
just for the record: Lightning-AI/pytorch-lightning#5451
and build: https://github.com/PyTorchLightning/pytorch-lightning/runs/1686819251?check_suite_focus=true#step:3:88
There is a possibility to auto-update PRs that are tagged with concrete labels. Another one is for non-draft PRs.
Can the new filtering be added, that auto-update would trigger only for PRs that got already reviewed?
I would love to not waste CPU power of CI to run on each auto-update merge for PR that is not yet reviewed
Seems like autoupdate is not able to update PRs from a fork?
It fails to update all the PRs coming from forks, with: Caught error trying to update branch: Resource not accessible by integration
Here's the full log from one of the PRs
Evaluating pull request #1883...
Checking PR ready state
PR_FILTER=all, checking if this PR's branch needs to be updated.
All checks pass and PR branch is behind base branch.
Updating branch 'opentracing-update' on pull request #1883 with changes from ref 'master'.
Attempting branch update...
Error: Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #0 of 5.
Hello Dear,
I am trying to run the auto-pull bot locally for using it in my private environment. Also, Trying to run it local docker desktop.
But, both local and docker run fail with the same error:
Is there a plan to release the latest version from the main branch? Docs says that the workflow_dispatch
event is supported, but I see that the PR that adds this support was merged after the latest release.
Add (configurable) ability to comment on PR if there's conflict when updating.
I am facing this error. Let me know what could we have done.
This is our workflow:
name: autoupdate
on:
push:
branches:
- main
pull_request:
types:
- auto_merge_enabled
jobs:
autoupdate:
name: autoupdate
runs-on: ubuntu-latest
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
PR_FILTER: "auto_merge"
MERGE_MSG: "Branch was auto-updated."
RETRY_COUNT: "5"
RETRY_SLEEP: "300"
MERGE_CONFLICT_ACTION: "ignore"
Output:
Evaluating pull request #99...
PR_FILTER=auto_merge, checking if this PR's branch needs to be updated.
Checking if this PR has auto_merge enabled.
Pull request has auto_merge enabled and is behind base branch.
Updating branch 'XYZ-602' on pull request #99 with changes from ref 'main'.
Attempting branch update...
Error: Caught error trying to update branch: Not Found
Branch update failed, will retry in 300ms, retry #0 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Not Found
Branch update failed, will retry in 300ms, retry #1 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Not Found
Branch update failed, will retry in 300ms, retry #2 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Not Found
Branch update failed, will retry in 300ms, retry #3 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Not Found
Branch update failed, will retry in 300ms, retry #4 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Not Found
Error: Caught error running merge, skipping and continuing with remaining PRs
Error: HttpError: Not Found
Anyone know of a way to reference the base_ref
and head_ref
in the commit message? Our normal commits that update with the base branch look like Merge 'main' into feature/name-of-head-branch
and looks like base_ref
and head_ref
are blank in pushes to main (makes sense), so would love a way to reference those two when the action finds a branch that needs updating.
Also take the opportunity to switch from @zeit/ncc
to @vercel/ncc
Hi @chinthakagodawita, thanks for putting this plugin together!
We found a potential bug that is hopefully an easy fix?
When a PR is originally being monitored and later gets put into "draft" mode the plugin fails with the error:
When a PR is being tracked and then set to "draft" mode the plugin does not fail.
Config
name: autoupdate
on:
push: {} # triggers on all pushes to all branches
jobs:
autoupdate:
name: autoupdate
runs-on: ubuntu-20.04
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
PR_READY_STATE: 'ready_for_review'
RETRY_COUNT: '1'
MERGE_CONFLICT_ACTION: 'fail'
I recently added this to a project which has CI automation that bumps the project version and pushes a new commit + release via a bot to the repo with every merged PR. This commit is always published with [skip ci]
so that the bot commits don't trigger new bot commits. The [skip ci]
however prevents the autoupdater from running on those commits. I'm wondering if you would be willing to add release
as a trigger event as a workaround?
Would be nice to have an option to only update the top N PRs or PRs newer than a certain date. This will help in keeping CI/CD costs low by skipping old or stale PRs.
Similar to #232 we'd like to use Auto Update to help with our "ready to be merged" queue, after all checks have passed. We already use GitHub's auto-merge feature and the combination with Auto Update would be a killer combo we think. Once everybody agrees that a PR can be merged we could activate auto merging and auto update would take care of keeping the PR up to date until its time has come (it might have to rebuild a couple of times because other PRs get merged in the meantime).
Would it be possible to add an auto_merge
condition to PR_FILTER
which evaluates to true if GitHub's auto-merge feature is activated for a PR?
Workaround: use a label instead
Hi,
I noticed, that if I open a PR from a fork, it isn't updated when destination branch has changes.
Evaluating pull request #287...
PR_FILTER=all, checking if this PR's branch needs to be updated.
All checks pass and PR branch is behind base branch.
Updating branch 'logger' on pull request #287 with changes from ref 'master'.
Attempting branch update...
Error: Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #0 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #1 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #2 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #3 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #4 of 5.
Attempting branch update...
Error: Caught error trying to update branch: Resource not accessible by integration
Error: Caught error running merge, skipping and continuing with remaining PRs
Error: HttpError: Resource not accessible by integration
Support the following additional merge types:
It is spelled labeled
in the GitHub pull_request event type, so it should be a recognized input for the PR filter. Both are correct spellings, so both should be allowed.
Hi,
When using the schedule event as the workflow trigger, should it target all PR's, or only PR's on the main branch? As you can see below it's only targeting develop (our main branch).
Here's my workflow:
name: auto-update
run-name: auto-update (${{github.event.schedule}})
on:
schedule:
- cron: '39 * * * 1-5' # every weekday hour
- cron: '5 6 * * 1-5' # every weekday
jobs:
autoupdate:
name: auto-update
runs-on: ubuntu-18.04
steps:
- name: auto-update-1h
if: github.event.schedule == '39 * * * 1-5'
uses: docker://chinthakagodawita/autoupdate-action:v1
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
DRY_RUN: 'false'
PR_FILTER: 'labelled'
PR_LABELS: 'auto_update_1h'
MERGE_MSG: 'auto-update from base'
RETRY_COUNT: '5'
RETRY_SLEEP: '300'
MERGE_CONFLICT_ACTION: 'ignore'
- name: auto-update-1d
if: github.event.schedule == '5 6 * * 1-5'
uses: docker://chinthakagodawita/autoupdate-action:v1
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
DRY_RUN: 'false'
PR_FILTER: 'labelled'
PR_LABELS: 'auto_update_1d'
MERGE_MSG: 'auto-update from base'
RETRY_COUNT: '5'
RETRY_SLEEP: '300'
MERGE_CONFLICT_ACTION: 'ignore'
Thanks
We were using this action to update branches and it worked fine for push
event. Now we are trying to add the capability for contributors to update their branch from PRs.
Since we are using forks for contributions and the pull_request
event causes the workflow to run on the fork, and forks don't have access to the secrets
, hence, this error will show up: https://github.com/asyncapi/glee/runs/5838503289?check_suite_focus=true
adding support for pull_request_target
may be the solution here.
Related to #212
Currently updates to PR sources only happen when a new commit is made on the destination. However, a PR can be created on destination branch while the source is already outdated and the update will not be triggered
When loading PR details, warn but don't error on 404s
We're using autoupdate as schedule
but we also want to set up the option to be able to trigger it manually, using workflow_dispatch
event type.
However, we see this is currently unsupported and it's giving an error:
Error: Unknown event type 'workflow_dispatch', only 'push', 'pull_request', 'workflow_run', and 'schedule' are supported.
Are there any plans to support this event type? This would be very helpful for our current set up.
Maybe use NCC for compilation?
Hello there
Just today when running Actions our merges to master started to fail with:
Getting action download info
Error: Unable to resolve actions. Repository not found : chinthakagodawita/autoupdate-action.
The workflow:
name: "Push Master Automations"
on:
push:
branches:
- master
jobs:
autoupdate-open-prs:
name: autoupdate
runs-on: ubuntu-18.04
steps:
- uses: chinthakagodawita/autoupdate-action@699da47083dddb66e5f5d2d48825b2e375a1d6c3
env:
GITHUB_TOKEN: "${{ secrets.BOT_GITHUB_TOKEN }}"
I'm currently investigating if updating helps or if removing the SHA from uses
might have something to do with the repository rename and subsecuent redirect, but cloning the repo seems to be working fine locally.
Hey. We were trying out the action in our project and it doesn't update the branch in PR (which belongs to a forked project) whenever a commit gets pushed to the repository.
I see the following error in the Actions
tab
Handling push event on ref 'refs/heads/master'
PR-425
Evaluating pull request #425...
PR_FILTER=all, checking if this PR's branch needs to be updated.
All checks pass and PR branch is behind base branch.
Updating branch 'testing' on pull request #425 with changes from ref 'master'.
Attempting branch update...
##[error]Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #0 of 5.
Attempting branch update...
##[error]Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #1 of 5.
Attempting branch update...
##[error]Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #2 of 5.
Attempting branch update...
##[error]Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #3 of 5.
Attempting branch update...
##[error]Caught error trying to update branch: Resource not accessible by integration
Branch update failed, will retry in 300ms, retry #4 of 5.
Attempting branch update...
##[error]Caught error trying to update branch: Resource not accessible by integration
##[error]Resource not accessible by integration
We are using the default yml config as mentioned in the documentation
Is this a limitation of this Github Action? Any help is really appreciated. Thanks!
If there are open PRs by dependabot in the repo, those PRs will not get updated by autoupdate when a PR is merged into main.
name: autoupdate
on:
push:
branches:
- master
permissions:
pull-requests: write
jobs:
autoupdate:
name: autoupdate
runs-on: ubuntu-latest
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_CONFLICT_ACTION: "ignore"
Error: Caught error trying to compare base with head: Resource not accessible by integration.
I had to add the following to get detailed error above , otherwise it would just give me a plain Resource not accessible by integration.
error
Branch protection is disabled and default permission is read/write
permissions:
pull-requests: write
Resource not accessible by integration.
Hey there!
This Github action looks amazing. It'd be sooo useful for a lot of my projects.
I've been trying to get it working on a repo I run, but having some permissions issues that I can't seem to figure out. Here's my config file:
name: autoupdate
on:
push: {}
jobs:
autoupdate:
name: autoupdate
runs-on: ubuntu-18.04
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
When the action goes to run, however, here's the output I see after looking at the job:
Any idea what I need to do to get it working? Also, just as a note, but this action was running on a local pull request for the same repository. Nothing fancy.
tsc
is better supported and (now) has less weirdness than ncc
.
While working in a high throughput repository we want to keep our CI load down and only auto-update the PRs once everybody is happy with them. There's no need to have GitHub update the PRs and the CI build them while a developer is still working on them and addressing the feedback. We'd like to use the auto-update to help working through our "waiting to be merged" queue.
Is it possible to add an "approved" condition to PR_READY_STATE
which evaluates to true once all required reviewers have approved a PR?
Seems like a very useful feature to have rebase instead of merge, I do see, according to the readme, it's on the roadmap.
In case the merge fails, add support for retries + support to configure retry logic (i.e. # of retries + perhaps amount of time to sleep between retries).
Hi there, our required workflow doesn't get triggered after autoupdate. It says Expected - Waiting for status to be reported
. Look at the attachment.
Here's our autoupdate.yaml file
name: autoupdate
on:
pull_request:
types: [auto_merge_enabled]
jobs:
autoupdate:
name: autoupdate
runs-on: ubuntu-18.04
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1
id: autoupdate
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
MERGE_CONFLICT_ACTION: 'fail'
- run: echo 'Merge conflicts found!'
if: ${{ steps.autoupdate.outputs.conflicted }}
- run: echo 'No merge conflicts'
if: ${{ !steps.autoupdate.outputs.conflicted }}
Here's our beginning of not triggered workflow yaml file if you want to see events that suppose to trigger the workflow. Any idea?
name: Build
on:
push:
pull_request:
types: [opened]
jobs:
test:
...
build:
Is there a way we can get a non-docker version? Using docker does not seem to be the norm for GitHub Actions, and there is some inherent risk with using a third party docker image. GitHub themselves suggest there is a higher risk for these actions saying:
Warning: When creating workflows and actions, you should always consider whether your code might execute untrusted input from possible attackers. Certain contexts should be treated as untrusted input, as an attacker could insert their own malicious content. For more information, see "Understanding the risk of script injections."
https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
To protect your code and data, we strongly recommend you verify the integrity of the Docker container image from Docker Hub before using it in your workflow.
For commitlint:
For semantic-release:
yarn run release
autoupdate-test
build-prod.sh
scriptHi, I saw in the README it says "Branch updates events caused by this action will not trigger any subsequent workflows". This is problematic because we need our unit tests to rerun on a PR whenever any new commit or update is pushed to that PR.
Is there any workaround so that normal builds run after the PR executes its action?
From the docs, both RETRY_COUNT
and RETRY_SLEEP
have a default value but I noticed that there is no retry attempt when we encounter this error:
Error: Caught error trying to compare base with head: You have exceeded a secondary rate limit. Please wait a few minutes before you try again.
I am guessing this is intentional since retrying too frequently will only contribute to the request rate and exacerbate the issue.
However, I am looking into circumventing the rate limit by setting a high-enough RETRY_SLEEP
. In my case, the alternative is waiting and manually triggering the auto-update job again so I don't mind if RETRY_SLEEP
is a very high value. I just don't want to have to manually intervene.
Is there a way to retry when encountering the rate limit?
Similar to #305, to limit CI/CD costs, would it be possible to add an extra PR filter to ensure only PRs that have already been fully approved are updated? This should limit the number of PRs that get updated and trigger CI checks whilst others are still in review.
Similar to #305, I'm looking into ways to reduce API calls made.
I can see here in prNeedsUpdate
:
Line 245 in 01c66da
that we have this API call this.octokit.rest.repos.compareCommitsWithBasehead
relatively early on:
Lines 263 to 272 in 01c66da
We don't check for PR_READY_STATE
and PR_FILTER
until further down, so this API call is made for all PRs that are still open. However, many of these checks would have returned false
early on if they were checked first.
I don't think compareCommitsWithBasehead
needs to run unless all the conditions pass? Could we change it so that it doesn't run until the end?
Github has changed the github token provided for push & pull_request events if triggered by dependabot to have read-only access. It would be useful if this could also work with the workflow_run as that is the default recommended way of having an untrusted workflow trigger a trusted workflow.
I'm not familiar enough with typescript/javascript to know exactly how to put together a suitable test so it might be a while before I'd be able to provide anything useful. At a rudimentary level I'm thinking something like the following would allow this to support the workflow_run event, though maybe it could be improved to reuse handlePush after setting up the correct eventData instead of duplicating it?:
async handleWorkflowRun(): Promise<number> {
const { workflow_run, repository } = this.eventData;
const ref = workflow_run.head_branch;
ghCore.info(`Handling workflow-run event triggered by '${workflow_run.workflow}'`);
if (!ref.startsWith('refs/heads/')) {
ghCore.warning('Workflow_run event was not triggered by an event on a branch, skipping.');
return 0;
}
const baseBranch = ref.replace('refs/heads/', '');
let updated = 0;
const paginatorOpts = this.octokit.pulls.list.endpoint.merge({
owner: repository.owner.name,
repo: repository.name,
base: baseBranch,
state: 'open',
sort: 'updated',
direction: 'desc',
});
let pullsPage: octokit.OctokitResponse<any>;
for await (pullsPage of this.octokit.paginate.iterator(paginatorOpts)) {
let pull: octokit.PullsUpdateResponseData;
for (pull of pullsPage.data) {
ghCore.startGroup(`PR-${pull.number}`);
const isUpdated = await this.update(pull);
ghCore.endGroup();
if (isUpdated) {
updated++;
}
}
}
ghCore.info(
`Auto update complete, ${updated} pull request(s) that point to base branch '${baseBranch}' were updated.`,
);
return updated;
}
Handling push event on ref 'refs/heads/develop'
PR-30
Evaluating pull request #30...
Error: Not Found
PR 30 does, in fact, exist so not sure what exactly is going on here internally. Using latest version. The PR is from a fork
This is my workflow yaml:
name: autoupdate
on:
push:
branches:
- develop
jobs:
autoupdate:
name: autoupdate
runs-on: ubuntu-latest
steps:
- uses: docker://chinthakagodawita/autoupdate-action:v1.5.0
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
Thoughts on adding a configuration value to support custom merge conflict messages similar to the existing MERGE_MSG
setting?
Examples in the README should probably be updated
autoupdate
This is a scheduled Ubuntu-18.04 brownout. The Ubuntu-18.04 environment is deprecated and will be removed on April 1st, 2023. For more details, see https://github.com/actions/runner-images/issues/6002
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.