Skip to content

Action fails when then branch is updated in PR by rebasing #43

@liny01-nbsa

Description

@liny01-nbsa

Thanks for making this action.

I recently noticed, for some of triggering PRs, if the user updated any out-of-date branch by clicking the update branch button and with rebase option selected. Then running this action would cause a failure.

From the log it looks the action is trying to checking staging branch which doesn't exist in the repo.

Failed log
Run endre-spotlab/fast-forward-js-action@2.1
RequestError [HttpError]: Update is not a fast forward
    at /home/runner/work/_actions/endre-spotlab/fast-forward-js-action/2.1/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  status: 422,
  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',
    connection: 'close',
    'content-length': '126',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Thu, 20 Oct 2022 20:42:02 GMT',
    'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
    server: 'GitHub.com',
    'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
    vary: 'Accept-Encoding, Accept, X-Requested-With',
    'x-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': '0703:0DFF:1FAD39A:40EF280:6351B29A',
    'x-ratelimit-limit': '1000',
    'x-ratelimit-remaining': '998',
    'x-ratelimit-reset': '1666302122',
    'x-ratelimit-resource': 'core',
    'x-ratelimit-used': '2',
    'x-xss-protection': '0'
  },
  request: {
    method: 'PATCH',
    url: 'https://api.github.com/repos/NYK-Business-Systems-Americas/roro-uber/git/refs/heads/next',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit.js/16.41.0 Node.js/12.22.7 (Linux 5.15; x64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: '{"sha":"db95c1f5048d641549d2d0ce63af99afd212a078","force":false}',
    request: { hook: [Function: bound bound register], validate: [Object] }
  },
  documentation_url: 'https://docs.github.com/rest/reference/git#update-a-reference'
}
RequestError [HttpError]: Branch not found
    at /home/runner/work/_actions/endre-spotlab/fast-forward-js-action/2.1/node_modules/@octokit/request/dist-node/index.js:66:23
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  status: 404,
  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',
    connection: 'close',
    'content-encoding': 'gzip',
    'content-security-policy': "default-src 'none'",
    'content-type': 'application/json; charset=utf-8',
    date: 'Thu, 20 Oct 2022 20:42:03 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-content-type-options': 'nosniff',
    'x-frame-options': 'deny',
    'x-github-media-type': 'github.v3; format=json',
    'x-github-request-id': '0707:50EF:218BF3A:44A71A8:6351B29B',
    'x-ratelimit-limit': '1000',
    'x-ratelimit-remaining': '994',
    'x-ratelimit-reset': '1666302122',
    'x-ratelimit-resource': 'core',
    'x-ratelimit-used': '6',
    'x-xss-protection': '0'
  },
  request: {
    method: 'GET',
    url: 'https://api.github.com/repos/NYK-Business-Systems-Americas/roro-uber/branches/staging',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit.js/16.41.0 Node.js/12.22.7 (Linux 5.15; x64)',
      authorization: 'token [REDACTED]'
    },
    request: { hook: [Function: bound bound register], validate: [Object] }
  },
  documentation_url: 'https://docs.github.com/rest/reference/repos#get-a-branch'
}
Workflow File
name: Fast-Forward PR

on:
  issue_comment:
    types: [created]

jobs:
  fast_forward_job:
    name: Fast Forward
    if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/fast-forward')
    runs-on: ubuntu-latest
    steps:
      # To use this repository's private action, you must check out the repository
      - name: Checkout code into workspace directory
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      # Basic use case example
      - name: Fast Forward PR
        uses: endre-spotlab/fast-forward-js-action@2.1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          success_message: 'Success! Fast forwarded ***target_base*** to ***source_head***! ```git checkout target_base && git merge source_head --ff-only``` '
          failure_message: 'Failed! Cannot do fast forward!'
          # staging_branch: 'main'
          # production_branch: 'prod'

In our use case, we typically merges pu/module/* branches into origin/next branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions