rebase icon indicating copy to clipboard operation
rebase copied to clipboard

Rebase command can not trigger test check workflow

Open jolestar opened this issue 5 years ago • 14 comments

the RP after rebase by /rebase command can not trigger test check workflow

jolestar avatar Oct 12 '20 03:10 jolestar

+1 I tryied to pass a custom token, but nothing changed... my test workflows don't fire.

    - name: Automatic Rebase
      uses: cirrus-actions/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.MY_GITHUB_API_TOKEN }}  

sebastianvarela avatar Oct 13 '20 09:10 sebastianvarela

+1

baumstern avatar Oct 14 '20 06:10 baumstern

This is a weird Actions limitation that one workflow can't trigger another one. See this community post for more details. I don't believe there is a viable workaround at the moment. On a bright side it does work with 3rdparty CIs like Travis, Circle and Cirrus.

fkorotkov avatar Oct 14 '20 13:10 fkorotkov

I tried adding

on:
  workflow_run:
    workflows: ["Automatic Rebase"]
    types: 
      - completed

to test workflow, it is run on default branch not within context of rebased pull request.

Documentation seemed promising

This event occurs when a workflow run is requested or completed, and allows you to execute a workflow based on the finished result of another workflow. For example, if your pull_request workflow generates build artifacts, you can create a new workflow that uses workflow_run to analyze the results and add a comment to the original pull request.

https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_run

But article about this feature clearly states that

Runs triggered by the workflow_run event always use the default branch for the repository

https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/

starsep avatar Oct 14 '20 14:10 starsep

This is a weird Actions limitation that one workflow can't trigger another one. See this community post for more details. I don't believe there is a viable workaround at the moment. On a bright side it does work with 3rdparty CIs like Travis, Circle and Cirrus.

this action https://github.com/Label305/AutoRebase can auto rebase and trigger CI workflow by use a personal github token.

I try to use a personal github token for cirrus-actions/rebase, but not work.

jolestar avatar Oct 15 '20 00:10 jolestar

I've worked around the issue by letting my GitHub Actions test workflow run also on pull request review events:

on: [push, pull_request_review]

Running /rebase will rebase the branch but the PR will be stuck waiting for the test workflow to finish but it doesn't even start (that's this issue). Approving a review will start it and run it again and then the test workflow finishes 🎉 GitHub can also optionally dismiss an existing review automatically prompting someone to approve the change again triggering the test workflow.

Not perfect but it works for me. Thank you for this rebase action 👍

spaze avatar Nov 16 '20 17:11 spaze

I've now created a PR with that workaround description because maybe more people might find it useful.

spaze avatar Nov 17 '20 03:11 spaze

Do you think this will be fixed anytime soon by the GHA team?

walterholohan avatar Dec 11 '20 08:12 walterholohan

@walterholohan Fixed here https://github.com/cirrus-actions/rebase/pull/70

jackton1 avatar Jan 07 '21 15:01 jackton1

@jackton1 I updated the action yaml file to

on:
  issue_comment:
    types: [created]
name: Automatic Rebase
jobs:
  rebase:
    name: Rebase
    if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
    runs-on: ubuntu-latest
    steps:
    - name: Checkout the latest code
      uses: actions/checkout@v2
      with:
        fetch-depth: 0 # otherwise, you will fail to push refs to dest repo,
        persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token.
    - name: Automatic Rebase
      uses: cirrus-actions/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.GH_PAT }}

where secrets.GH_PAT is a PAT that I have setup. However this did not solve the issue. After a successful rebase by thecirrus-actions/[email protected] action it did not trigger a new check workflow. Am I missing something from the above snippet?

walterholohan avatar Jan 07 '21 18:01 walterholohan

@walterholohan it seems actions/checkout@v2 fails with the default github.token

Update

name: Automatic Rebase
on:
  issue_comment:
    types: [created]
jobs:
  rebase:
    name: Rebase
    if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.PAT_TOKEN }}
          fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
      - name: Automatic Rebase
        uses: cirrus-actions/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}

jackton1 avatar Jan 07 '21 20:01 jackton1

@jackton1 ive changed to the above suggestion but still no luck. The rebase completed successfully but the actions did not get triggered. Does the PAT need certain permissions? Maybe its missing something.

walterholohan avatar Jan 08 '21 16:01 walterholohan

@walterholohan Try again using Screen Shot 2021-01-11 at 7 49 19 PM

Note for workflows that modify github actions you can enable

Screen Shot 2021-01-11 at 7 50 39 PM

jackton1 avatar Jan 12 '21 00:01 jackton1

Thank you, It was an issue on my end. I was trying to test this out in a PR but when I triggered a rebase by adding a /rebase comment it what using the workflow from the develop branch instead of the PR. Once I merged the PR it worked. I also added persist-credentials: false to the checkout action

walterholohan avatar Jan 12 '21 13:01 walterholohan