Giter VIP home page Giter VIP logo

cascading-downstream-merge's Introduction

cascading-downstream-merge's People

Contributors

bakosa avatar jdesulme avatar jefeish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

jefeish jonweeks

cascading-downstream-merge's Issues

Issue with Secondary Rate Limit

Hello we recently switched from bitbucket to github enterprise. I have your project setup in github actions. I keep running into Secondary Rate Limit issues. Is there any advice to get around this?

I have sanitized the logs from the github action.

Run ActionsDesk/[email protected]
  with:
    GITHUB_TOKEN: ***
    prefixes: release/
    refBranch: master
owner: [organization]
repo: [repo]
actor: [user]
prefixes: release/
prefixArray:  [ 'release/' ]
refBranch: master
pullNumber: 45
headBranch: release/4.23.2
baseBranch: release/4.23.3
Context {
  payload: {
    action: 'closed',
    enterprise: {
      avatar_url: 'https://avatars.githubusercontent.com/b/9738?v=4',
      created_at: '2021-10-21T16:50:46Z',
      description: '',
      html_url: 'https://github.com/enterprises/[enterprise]',
      id: 9738,
      name: '[enterprise]',
      node_id: 'E_kgDNJgo',
      slug: '[enterprise]',
      updated_at: '2023-09-21T11:42:40Z',
      website_url: ''
    },
    number: 45,
    organization: {
      avatar_url: 'https://avatars.githubusercontent.com/u/[userid]?v=4',
      description: '',
      events_url: 'https://api.github.com/orgs/[organization]/events',
      hooks_url: 'https://api.github.com/orgs/[organization]/hooks',
      id: [userid],
      issues_url: 'https://api.github.com/orgs/[organization]/issues',
      login: '[organization]',
      members_url: 'https://api.github.com/orgs/[organization]/members{/member}',
      node_id: 'O_kgDOCD00-w',
      public_members_url: 'https://api.github.com/orgs/[organization]/public_members{/member}',
      repos_url: 'https://api.github.com/orgs/[organization]/repos',
      url: 'https://api.github.com/orgs/[organization]'
    },
    pull_request: {
      _links: [Object],
      active_lock_reason: null,
      additions: 1,
      assignee: null,
      assignees: [],
      author_association: 'CONTRIBUTOR',
      auto_merge: null,
      base: [Object],
      body: null,
      changed_files: 1,
      closed_at: '2024-01-26T22:47:43Z',
      comments: 0,
      comments_url: 'https://api.github.com/repos/[organization]/[repo]/issues/45/comments',
      commits: 1,
      commits_url: 'https://api.github.com/repos/[organization]/[repo]/pulls/45/commits',
      created_at: '2024-01-26T22:47:37Z',
      deletions: 1,
      diff_url: 'https://github.com/[organization]/[repo]/pull/45.diff',
      draft: false,
      head: [Object],
      html_url: 'https://github.com/[organization]/[repo]/pull/45',
      id: 1697890000,
      issue_url: 'https://api.github.com/repos/[organization]/[repo]/issues/45',
      labels: [],
      locked: false,
      maintainer_can_modify: false,
      merge_commit_sha: '3ddb32edd425cb1e1c302cf430ff79b00a6f7360',
      mergeable: null,
      mergeable_state: 'unknown',
      merged: true,
      merged_at: '2024-01-26T22:47:43Z',
      merged_by: [Object],
      milestone: null,
      node_id: 'PR_kwDOKqbyxM5lM77Q',
      number: 45,
      patch_url: 'https://github.com/[organization]/[repo]/pull/45.patch',
      rebaseable: null,
      requested_reviewers: [],
      requested_teams: [],
      review_comment_url: 'https://api.github.com/repos/[organization]/[repo]/pulls/comments{/number}',
      review_comments: 0,
      review_comments_url: 'https://api.github.com/repos/[organization]/[repo]/pulls/45/comments',
      state: 'closed',
      statuses_url: 'https://api.github.com/repos/[organization]/[repo]/statuses/f3eec81fd7910e5be1d93ab66581e11e197614b7',
      title: 'Update merge.yml',
      updated_at: '2024-01-26T22:47:43Z',
      url: 'https://api.github.com/repos/[organization]/[repo]/pulls/45',
      user: [Object]
    },
    repository: {
      allow_forking: true,
      archive_url: 'https://api.github.com/repos/[organization]/[repo]/{archive_format}{/ref}',
      archived: false,
      assignees_url: 'https://api.github.com/repos/[organization]/[repo]/assignees{/user}',
      blobs_url: 'https://api.github.com/repos/[organization]/[repo]/git/blobs{/sha}',
      branches_url: 'https://api.github.com/repos/[organization]/[repo]/branches{/branch}',
      clone_url: 'https://github.com/[organization]/[repo].git',
      collaborators_url: 'https://api.github.com/repos/[organization]/[repo]/collaborators{/collaborator}',
      comments_url: 'https://api.github.com/repos/[organization]/[repo]/comments{/number}',
      commits_url: 'https://api.github.com/repos/[organization]/[repo]/commits{/sha}',
      compare_url: 'https://api.github.com/repos/[organization]/[repo]/compare/{base}...{head}',
      contents_url: 'https://api.github.com/repos/[organization]/[repo]/contents/{+path}',
      contributors_url: 'https://api.github.com/repos/[organization]/[repo]/contributors',
      created_at: '2023-11-07T12:45:56Z',
      custom_properties: {},
      default_branch: 'master',
      deployments_url: 'https://api.github.com/repos/[organization]/[repo]/deployments',
      description: 'Project = CME and BB Repo URL = https://scm-git-eur.misys.global.ad/projects/CME/repos/bizcomp_booking',
      disabled: false,
      downloads_url: 'https://api.github.com/repos/[organization]/[repo]/downloads',
      events_url: 'https://api.github.com/repos/[organization]/[repo]/events',
      fork: false,
      forks: 0,
      forks_count: 0,
      forks_url: 'https://api.github.com/repos/[organization]/[repo]/forks',
      full_name: '[organization]/[repo]',
      git_commits_url: 'https://api.github.com/repos/[organization]/[repo]/git/commits{/sha}',
      git_refs_url: 'https://api.github.com/repos/[organization]/[repo]/git/refs{/sha}',
      git_tags_url: 'https://api.github.com/repos/[organization]/[repo]/git/tags{/sha}',
      git_url: 'git://github.com/[organization]/[repo].git',
      has_discussions: false,
      has_downloads: false,
      has_issues: true,
      has_pages: false,
      has_projects: true,
      has_wiki: false,
      homepage: null,
      hooks_url: 'https://api.github.com/repos/[organization]/[repo]/hooks',
      html_url: 'https://github.com/[organization]/[repo]',
      id: 715584196,
      is_template: false,
      issue_comment_url: 'https://api.github.com/repos/[organization]/[repo]/issues/comments{/number}',
      issue_events_url: 'https://api.github.com/repos/[organization]/[repo]/issues/events{/number}',
      issues_url: 'https://api.github.com/repos/[organization]/[repo]/issues{/number}',
      keys_url: 'https://api.github.com/repos/[organization]/[repo]/keys{/key_id}',
      labels_url: 'https://api.github.com/repos/[organization]/[repo]/labels{/name}',
      language: 'Java',
      languages_url: 'https://api.github.com/repos/[organization]/[repo]/languages',
      license: null,
      merges_url: 'https://api.github.com/repos/[organization]/[repo]/merges',
      milestones_url: 'https://api.github.com/repos/[organization]/[repo]/milestones{/number}',
      mirror_url: null,
      name: '[repo]',
      node_id: 'R_kgDOKqbyxA',
      notifications_url: 'https://api.github.com/repos/[organization]/[repo]/notifications{?since,all,participating}',
      open_issues: 2,
      open_issues_count: 2,
      owner: [Object],
      private: true,
      pulls_url: 'https://api.github.com/repos/[organization]/[repo]/pulls{/number}',
      pushed_at: '2024-01-26T22:47:43Z',
      releases_url: 'https://api.github.com/repos/[organization]/[repo]/releases{/id}',
      size: 28103,
      ssh_url: '[email protected]:[organization]/[repo].git',
      stargazers_count: 0,
      stargazers_url: 'https://api.github.com/repos/[organization]/[repo]/stargazers',
      statuses_url: 'https://api.github.com/repos/[organization]/[repo]/statuses/{sha}',
      subscribers_url: 'https://api.github.com/repos/[organization]/[repo]/subscribers',
      subscription_url: 'https://api.github.com/repos/[organization]/[repo]/subscription',
      svn_url: 'https://github.com/[organization]/[repo]',
      tags_url: 'https://api.github.com/repos/[organization]/[repo]/tags',
      teams_url: 'https://api.github.com/repos/[organization]/[repo]/teams',
      topics: [],
      trees_url: 'https://api.github.com/repos/[organization]/[repo]/git/trees{/sha}',
      updated_at: '2023-11-07T12:47:34Z',
      url: 'https://api.github.com/repos/[organization]/[repo]',
      visibility: 'private',
      watchers: 0,
      watchers_count: 0,
      web_commit_signoff_required: false
    },
    sender: {
      avatar_url: 'https://avatars.githubusercontent.com/u/[userid]?v=4',
      events_url: 'https://api.github.com/users/[user]/events{/privacy}',
      followers_url: 'https://api.github.com/users/[user]/followers',
      following_url: 'https://api.github.com/users/[user]/following{/other_user}',
      gists_url: 'https://api.github.com/users/[user]/gists{/gist_id}',
      gravatar_id: '',
      html_url: 'https://github.com/[user]',
      id: [userid],
      login: '[user]',
      node_id: 'U_kgDOCRXhNw',
      organizations_url: 'https://api.github.com/users/[user]/orgs',
      received_events_url: 'https://api.github.com/users/[user]/received_events',
      repos_url: 'https://api.github.com/users/[user]/repos',
      site_admin: false,
      starred_url: 'https://api.github.com/users/[user]/starred{/owner}{/repo}',
      subscriptions_url: 'https://api.github.com/users/[user]/subscriptions',
      type: 'User',
      url: 'https://api.github.com/users/[user]'
    }
  },
  eventName: 'pull_request',
  sha: '3ddb32edd425cb1e1c302cf430ff79b00a6f7360',
  ref: 'refs/heads/release/4.23.3',
  workflow: 'Automatic Branch Merging',
  action: '__ActionsDesk_cascading-downstream-merge',
  actor: '[user]',
  job: 'Merge',
  runNumber: 12,
  runId: 7674246159,
  apiUrl: 'https://api.github.com',
  serverUrl: 'https://github.com',
  graphqlUrl: 'https://api.github.com/graphql'
}
Found 12 branches on repo [repo].
getBranchMergeOrder - branchList:  [
  'release/0.422',
  'release/1.0',
  'release/4.23.2',
  'release/4.23.3',
  'release/4.23.5',
  'release/4.23.6',
  'release/4.24',
  'release/4.25',
  'release/4.25.2',
  'release/4.25.3',
  'release/4.25.4'
]
getBranchMergeOrder - branchList:  [
  'release/0.422',
  'release/1.0',
  'release/4.23.2',
  'release/4.23.3',
  'release/4.23.5',
  'release/4.23.6',
  'release/4.24',
  'release/4.25',
  'release/4.25.2',
  'release/4.25.3',
  'release/4.25.4'
]
mergeListHead: [
  'release/4.23.2',
  'release/4.23.3',
  'release/4.23.5',
  'release/4.23.6',
  'release/4.24',
  'release/4.25',
  'release/4.25.2',
  'release/4.25.3',
  'release/4.25.4'
]
mergeListBase: [
  'release/4.23.3',
  'release/4.23.5',
  'release/4.23.6',
  'release/4.24',
  'release/4.25',
  'release/4.25.2',
  'release/4.25.3',
  'release/4.25.4',
  'master'
]
/home/runner/work/_actions/ActionsDesk/cascading-downstream-merge/v1.2.0/dist/index.js:5621
      const error = new import_request_error.RequestError(toErrorMessage(data), status, {
                    ^
 
RequestError [HttpError]: You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID 7DC3:7C77:14C22A:2AA56B:65B4369B.
    at /home/runner/work/_actions/ActionsDesk/cascading-downstream-merge/v1.2.0/dist/index.js:5621:21
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async cascadingBranchMerge (/home/runner/work/_actions/ActionsDesk/cascading-downstream-merge/v1.2.0/dist/index.js:29024:32) {
  status: 403,
  response: {
    url: 'https://api.github.com/repos/[organization]/[repo]/issues',
    status: 403,
    headers: {
      'access-control-allow-origin': '*',
      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Fri, 26 Jan 2024 22:47:55 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'transfer-encoding': 'chunked',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-github-permissions': 'issues=write',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '7DC3:7C77:14C22A:2AA56B:65B4369B',
      'x-ratelimit-limit': '15000',
      'x-ratelimit-remaining': '14988',
      'x-ratelimit-reset': '1706312242',
      'x-ratelimit-resource': 'core',
      'x-ratelimit-used': '12',
      'x-xss-protection': '0'
    },
    data: {
      message: 'You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID 7DC3:7C77:14C22A:2AA56B:65B4369B.',
      documentation_url: 'https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits'
    }
  },
  request: {
    method: 'POST',
    url: 'https://api.github.com/repos/[organization]/[repo]/issues',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-core.js/5.0.2 Node.js/20.8.1 (linux; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"assignees":["[user]"],"title":":heavy_exclamation_mark: Problem with cascading Auto-Merge","body":"Unknown issue when creating a PR to merge \\"__release/4.23.2__\\" into \\"__release/4.23.3__\\"\\n              Please try to resolve the issue. **Cascading Auto-Merge has been stopped!**\\n              error: \\"{\\"message\\":\\"You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID 7DC3:7C77:14C1E5:2AA4DE:65B4369B.\\",\\"documentation_url\\":\\https://docs.github.com/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits\\}\\""}',
    request: {
      agent: Agent {
        _events: [Object: null prototype] {
          free: [Function (anonymous)],
          newListener: [Function: maybeEnableKeylog]
        },
        _eventsCount: 2,
        _maxListeners: undefined,
        defaultPort: 443,
        protocol: 'https:',
        options: [Object: null prototype] {
          keepAlive: true,
          scheduling: 'lifo',
          timeout: 5000,
          noDelay: true,
          path: null
        },
        requests: [Object: null prototype] {},
        sockets: [Object: null prototype] {},
        freeSockets: [Object: null prototype] {},
        keepAliveMsecs: 1000,
        keepAlive: true,
        maxSockets: Infinity,
        maxFreeSockets: 256,
        scheduling: 'lifo',
        maxTotalSockets: Infinity,
        totalSocketCount: 0,
        maxCachedSessions: 100,
        _sessionCache: { map: {}, list: [] },
        [Symbol(kCapture)]: false
      },
      fetch: [Function: proxyFetch],
      hook: [Function: bound bound register]
    }
  }
}
 
Node.js v20.8.1

Documentation Updates

The contract has changed slightly on the implementation. We're now using another Github app and its associated token to perform the commit. In addition, we're also explicitly setting the permissions on the GITHUB_TOKEN provided by the repo. The samples and the docs need to be updated to detail this new implementation.

Add ability to use action token and GitHub App token

We should enable the ability to use the standard workflow action token in tandem with the github app token. The GitHub app token would be used for merging the PRs created by the standard action token. This way, the GitHub app has less scope over it's repositories.

Add option to delete branch after merge

Just a guess, but I would assume some teams will want to have their feature branches delete after merge. The native feature will break the cascade.. so we should add a new feature to allow the action to delete the feature branch once the cascade completes successfully if they want.

Implement pagination for branches

There are some repositories with more than 100 branches. The code needs to implement pagination on the listBranches function to support large repositories

Branch Deletion in PR prior to Action running

Users DELETE their branch after merging while the action is running.. causes a 422 because the branch was deleted.. we should try and block this.. and handle the error better if we can't.

Log Error: Handle 422 {"resource":"PullRequest","field":"head","code":"invalid"}

Merge status checks cause cascade action to fail!

When merge status checks like Jenkins or bamboo build are required for PR merge on the branch protection, the action will fail to merge the PR. When this error happens, we handle it like a merge conflict which is wrong.

We should handle the 405 for conflicts specifically and raise a real failed issue in this case!!

We may want to look into making the flow do actual direct pushes to the branches instead of PRs UNLESS a conflict is hit, then open a PR. Maybe this is optional? idk... that is what BitBucket does as well....

Refactor code

Refactor code to have better reuse and consistency in both error handling and verbiage.

The code is a bit redundant in the final merge and forward merges. We should abstract some of the calls into a function and also make the verbiage a bit more consistent/clear in issues/pr names etc.

Unit tests should continue to pass with the addition of handling 422s on the default branch merge which is not there today.

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.