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

Failure due to Error: Resource not accessible by integration #4

Closed
pattacini opened this issue May 20, 2022 · 13 comments
Closed

Failure due to Error: Resource not accessible by integration #4

pattacini opened this issue May 20, 2022 · 13 comments

Comments

@pattacini
Copy link

As per the title:

image

Here's the relevant snippet: https://github.com/robotology/icub-main/blob/master/.github/workflows/ci.yml#L35-L37.

Just posting a snapshot too as I'm very likely going to patch it.

image

@pattacini
Copy link
Author

I forgot to say that the failure happens for pull requests generated by forks.
And the reason for that is probably explained here: https://github.com/styfle/cancel-workflow-action#advanced-pull-requests-from-forks.

@pattacini
Copy link
Author

Replacing the standard GITHUB_TOKEN with a proper secret with repo and workflows scope didn't help.

@olekspickle
Copy link

olekspickle commented May 23, 2022

I reproduced it with my toy repo, honestly I hoped it would just work :)

@pattacini
Copy link
Author

Thanks for testing @alekspickle 👍🏻
Keep me posted if you find a way to get around this inconvenience!

@pattacini
Copy link
Author

pattacini commented Jun 3, 2022

Just for your information, there's no way that a workflow triggered by a pull_request generated by a public fork can have access to the repo secrets for having the necessary write permissions to cancel a job.

What I did was to trigger a workflow_run type CI to cancel the caller.

Here's an example: https://github.com/robotology/icub-main/blob/master/.github/workflows/cancel-ci-draft-pr.yml.

@sigprof
Copy link

sigprof commented Jul 3, 2022

This particular case may be solved even without cancelling the workflow — a condition like this added to the build job should work:

    if: >-
      !( (github.event_name == 'pull_request') && github.event.pull_request.draft )

The real problem is when the workflow actually has multiple jobs (not just a single job with a matrix), there is some parallelism in the job dependencies (so multiple different jobs can be running at the same time), and you want to cancel the whole workflow immediately when one of those jobs fails:

  • The strategy.fail-fast option does not work in this case (it can cancel only other instances of the same job, but does nothing for other jobs that might be running).
  • The workflow does not have the permissions to cancel itself if it was triggered by a pull_request from a fork (GITHUB_TOKEN is restricted, and there is no access to secrets to provide another token).
  • There is no event that gets triggered on a job failure, so you cannot even start another workflow which would have the permissions to cancel the broken workflow run. Even though a failed job should show up as a failed check for the commit, the check_run event is not triggered when the check was performed by GitHub Actions (apparently only third-party checks can trigger it).

@pattacini
Copy link
Author

pattacini commented Jul 4, 2022

Hi @sigprof

I know that one can use the if condition but I thought that ( (github.event_name == 'pull_request') && github.event.pull_request.draft ) can be somehow problematic as the pull_request payload checked by the second logic operation may be only available for events of type pull_request, actually. The if might be also cut short because of the and condition, so the result of the first operation may be sufficient when it is false, but I don't think it's a good pattern anyhow.

I didn't check honestly if it could have worked out and I explored some more articulated options with the idea that I wanted to make the job show up eventually as canceled in the action dashboard instead of being marked as failed.

Long story short, I learned a lot and came up with a solution based on the workflow_run event, which basically allows us to queue workflows and thus address point 2 and point 3 of your list.

Check out https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run for more details, especially for what regards the possibility to run a workflow based on the conclusion of another workflow.

jsjoeio added a commit to jsjoeio/code-server that referenced this issue Sep 22, 2022
Looks like the cancel action workflow can't run on forks due to secrets.

See andymckay/cancel-action#4
jsjoeio added a commit to coder/code-server that referenced this issue Sep 22, 2022
* refactor: remove stylelint

* refactor: move shellcheck to separate job

* refactor: add helm script and job

* refactor: add eslint job and yarn script

* fix(test/tsconfig): exclude test-plugin

* refactor: delete lint, add typecheck job

* refactor: remove prebuild

* wip: add notes about unit test refactor

* refactor: delete buggy socket test

This test was really added to in get cover specific lines but it's buggy
and only passes sometimes locally. I think it's okay to remove because:
- it's an implementation detail (not user facing)
- not preventing any specific regressions

* refactor: move test-plugin to integration suite

This seems more appropriate given this tests how a plugin might work
within code-server.

* wip

* wip: refactor vscode integration tests

* refactor: move unit tests to separate job

* fix: formatting

* Revert "wip: refactor vscode integration tests"

This reverts commit 13286bf.

* Revert "refactor: move unit tests to separate job"

This reverts commit 6c87b54.

* feat: collect codecov integration tests

* fixup! feat: collect codecov integration tests

* fixup! feat: collect codecov integration tests

* fixup!: move helm step

* fixup!: update ids for caching

* trigger ci

* trigger ci

* chore: clean up names in security.yaml

* fixup!: remove .tsx

* fixup!: change to src/**"

* fixup!: move helm cmd to yaml

* fixup!: always build test plugin

* fixup!: fix plugin typings

* fixup! add back flakey test

* fixup!: only install helm deps if changes

* fixup!: revert node mod caching

* dont keep, test for asher

* fixup!: add make to centos

* refactor: add test:native

This adds a new script to run native tests (i.e. --help which should run
in ci on all platforms).

* try updating glibc

* try 2.25

* Revert "refactor: move test-plugin to integration suite"

This reverts commit bc02005.

I couldn't get past some GLIBC errors in CI so moving back to unit
tests.

* Revert "try updating glibc"

This reverts commit 02ed560.

* fixup!

* asher: again

* try this for ts changes

* fixup

* refactor: scripts.yml -> scripts.yaml

* fixup!: move lint-sh to scripts.yaml

* fixup!: use apk for lint scripts

* fixup! fixup!: use apk for lint scripts

* fixup!: remove typecheck step

* fix: pattern for lint ts files

* test: lint should fail

* fixup! fixup!: use apk for lint scripts

* Revert "test: lint should fail"

This reverts commit 158c64d.

* fixup!: skip cancel workflow on forks

Looks like the cancel action workflow can't run on forks due to secrets.

See andymckay/cancel-action#4

* fixup: remove cancel-workflow

* fixup! fixup! fixup!: use apk for lint scripts

* fixup! fixup! fixup!: use apk for lint scripts

* fixup!: fix yarn key

* fixup!: add fetch-depth 0
@andymckay
Copy link
Owner

Glad you found a workaround for your case 👍🏾

@andymckay andymckay closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2022
@TamimiGitHub
Copy link

I'm still getting the Resource not accessible by integration error when attempting to cancel the workflow. This action is triggered on merge, so has nothing to do with PRs.

Wondering if this issue persists to someone else?

@albinahlback
Copy link

Yeah, I get this when using certain actions (in my case ilammy/msvc-dev-cmd).

@mxcl
Copy link

mxcl commented May 28, 2023

upgrading to 0.3 fixed this for me.

If this action had a v0 tag I wouldn't have even seen this bug. Just saying.

@ivankovnatsky
Copy link

ivankovnatsky commented Jul 3, 2023

On 0.3 version, had to add:

permissions:
  actions: write

@paulz
Copy link

paulz commented Oct 20, 2023

when we tried to permission, job fails to checkout:

  Error: fatal: repository 'https://github.com/.../' not found
  Error: The process '.../git' failed with exit code 128

when adding:

   permissions:
      actions: write 

at the job level

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

9 participants