Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not stop previous workflows if the PR is made from a fork. #65

Closed
dvkruchinin opened this issue Apr 7, 2021 · 3 comments
Closed

Comments

@dvkruchinin
Copy link

Hi.

I implemented it in my fork, but for some reason the previous workflows don't stop if I updated the PR.
Part of main.yml:

name: CI
on:
  push:
    branches:
      - 'master'
      - 'develop'
  pull_request:
    branches:
      - '*'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Cancel previous runs
        uses: styfle/cancel-workflow-action@0.8.0
        with:
          access_token: ${{ github.token }}
      - uses: actions/checkout@v2
      ...

cancel.yml:

name: Cancel
on:
  workflow_run:
    workflows: ["CI"]
    types:
      - requested
jobs:
  cancel:
    runs-on: ubuntu-latest
    steps:
    - uses: styfle/cancel-workflow-action@0.8.0
      with:
        workflow_id: ${{ github.event.workflow.id }}

When creating a PR from the current repository, it works fine.
But when creating a PR from a fork. No reaction.
From main.yml I got an error:

Found 6 runs for workflow 4551668 on branch check-workflow-canceling
- https://github.com/dvkruchinin/cvat/actions/runs/726508310
- https://github.com/dvkruchinin/cvat/actions/runs/726502076
- https://github.com/dvkruchinin/cvat/actions/runs/726489962
- https://github.com/dvkruchinin/cvat/actions/runs/726361555
- https://github.com/dvkruchinin/cvat/actions/runs/726315700
- https://github.com/dvkruchinin/cvat/actions/runs/726311604
with 2 runs to cancel.
Canceling run:  {
  id: 726502076,
  head_sha: '49509b67436b6704a7151bcdfd670e2b079622d4',
  status: 'in_progress',
  html_url: 'https://github.com/dvkruchinin/cvat/actions/runs/726502076'
}
Error while canceling workflow_id 4551668: Resource not accessible by integration

Please tell me what I'm doing wrong?

@styfle
Copy link
Owner

styfle commented Apr 11, 2021

cc @ericmatte who added this in #50

cc @pllim who added this in #55

@pllim
Copy link
Contributor

pllim commented Apr 11, 2021

Don't put the cancel in main.yml CI. It won't work there. Check the log in Cancel. I bet that one still work.

tl:dr; delete cancel step from main.yml

@styfle styfle closed this as completed May 28, 2021
@rfay
Copy link

rfay commented Dec 24, 2021

I don't think cancelling in a PR works at all. The access_token: ${{ github.token }} isn't provided on a forked PR is it?

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

No branches or pull requests

4 participants