Giter VIP home page Giter VIP logo

autoupdate's Introduction

Hi there ๐Ÿ‘‹

autoupdate's People

Contributors

adrian-gomez avatar anarast avatar chinthakagodawita avatar dependabot-preview[bot] avatar dependabot[bot] avatar ken-matsui avatar mfranzke avatar pjohnmeyer avatar vanessayuenn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

autoupdate's Issues

Feature Request: Option to exclude draft PRs

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".

Continue even if some PRs fails

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

Feature request: filter by review state

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

Caught error trying to update branch: Resource not accessible by integration

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.

"::error::The path argument must be of type string" occurs when run auto-update bot locally and on Docker desktop environment.

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:

image

image

  1. Could you advise how can I make the action-bot run in locally and a local docker container? Should I create my own .env variables in this case?
  2. Is it possible to use an action-bot for the GitHub Enterprise?

Plans for new release?

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 conflict support

Add (configurable) ability to comment on PR if there's conflict when updating.

Caught error trying to update branch: Not Found

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

Reference base and head refs in commit message

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.

PR not found after initially being monitored

Background

Hi @chinthakagodawita, thanks for putting this plugin together!

We found a potential bug that is hopefully an easy fix?

Current Behavior

When a PR is originally being monitored and later gets put into "draft" mode the plugin fails with the error:

Screen Shot 2021-09-16 at 1 51 22 PM

Expected Behavior

When a PR is being tracked and then set to "draft" mode the plugin does not fail.

Appendix

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'

Feature request: Add release as a trigger event

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?

feature: Limit number of PRs to update

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.

Add auto_merge to PR_FILTER

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

`Resource not accesible by integration`

Hi,
I noticed, that if I open a PR from a fork, it isn't updated when destination branch has changes.

there is a following error
 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

Allow 'labeled' as PR Filter Input

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.

Schedule event only targetting PR's on main branch

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).

image

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

support `pull_request_target` event

Context

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.

Problem

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

Possible solution

adding support for pull_request_target may be the solution here.

Related to #212

Feature request - Add support for workflow dispatch event

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.

Unable to resolve actions. Repository not found

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.

Caught error trying to update branch: Resource not accessible by integration

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!

Add documentation

  • Screenshots
  • Config var description
  • Examples:
    • On push
    • On PR
    • On push but only certain base branches

PRs open by dependabot don't get updated

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.

Permission issues?

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:

Screenshot from 2021-01-06 11-54-33

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.

Add support "approved" for PR_READY_STATE

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?

Add retry logic

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).

Does not trigger github workflow after auto update merge

Hi there, our required workflow doesn't get triggered after autoupdate. It says Expected - Waiting for status to be reported. Look at the attachment.

Screen Shot 2022-07-18 at 1 33 05 PM

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:

Non-docker version?

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.

https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions#referencing-a-container-on-docker-hub

Add commitlint, semantic-release and auto CHANGELOG generation

For commitlint:

  • Add Github Action that checks commits and fails if linting doesn't pass
  • Add pre-commit hook that checks your commit message

For semantic-release:

  • Triggered manually (for now, till we can automate the next step) - maybe via yarn run release
  • Warns you to make sure you've tested against autoupdate-test
  • If you confirm, creates a release and triggers the build-prod.sh script
  • Creates a CHANGELOG

Getting builds to run when action triggered on a PR?

Hi, 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?

Retry when encountering secondary rate limit

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?

feature: Add filter for PRs that have met minimum approvals

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.

Prioritize PR checks that don't require REST API calls first

Similar to #305, I'm looking into ways to reduce API calls made.

I can see here in prNeedsUpdate:

async prNeedsUpdate(pull: PullRequest): Promise<boolean> {

that we have this API call this.octokit.rest.repos.compareCommitsWithBasehead relatively early on:

try {
const { data: comparison } =
await this.octokit.rest.repos.compareCommitsWithBasehead({
owner: pull.head.repo.owner.login,
repo: pull.head.repo.name,
// This base->head, head->base logic is intentional, we want
// to see what would happen if we merged the base into head not
// vice-versa. This parameter expects the format {base}...{head}.
basehead: `${pull.head.label}...${pull.base.label}`,
});

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?

Security improvements means this action doesn't work if triggered by push from dependabot

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;
  }

autoupdate failing with 404 not found

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 }}'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.