Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Rebase command can not trigger test check workflow #65

Open
jolestar opened this issue Oct 12, 2020 · 14 comments
Open

Rebase command can not trigger test check workflow #65

jolestar opened this issue Oct 12, 2020 · 14 comments

Comments

@jolestar
Copy link

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

@sebastianvarela
Copy link

sebastianvarela commented Oct 13, 2020

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

    - name: Automatic Rebase
      uses: cirrus-actions/rebase@1.3.1
      env:
        GITHUB_TOKEN: ${{ secrets.MY_GITHUB_API_TOKEN }}  

@baumstern
Copy link

+1

@fkorotkov
Copy link
Member

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.

@starsep
Copy link

starsep commented Oct 14, 2020

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/

@jolestar
Copy link
Author

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.

@spaze
Copy link
Contributor

spaze commented Nov 16, 2020

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
Copy link
Contributor

spaze commented Nov 17, 2020

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

@walterholohan
Copy link

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

@jackton1
Copy link
Contributor

jackton1 commented Jan 7, 2021

@walterholohan Fixed here #70

@walterholohan
Copy link

@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/rebase@1.4
      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/rebase@1.4 action it did not trigger a new check workflow. Am I missing something from the above snippet?

@jackton1
Copy link
Contributor

jackton1 commented Jan 7, 2021

@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/rebase@1.4
        env:
          GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}

@walterholohan
Copy link

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

@jackton1
Copy link
Contributor

@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

@walterholohan
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants