Cache: Runs triggered by merging pull requests have no read/write permissions

Created on 20 Jul 2020  路  3Comments  路  Source: actions/cache

Runs that are triggered by merging pull requests, like

on:
  pull_request:
    types: [closed]

Have no access to cache even though GITHUB_REF is defined.

The following errors are returned when trying to read or write:

[warning]getCacheEntry failed: No scopes with read permission were found on the request.
...
[warning]reserveCache failed: No scopes with write permission were found on the request.

I created a very minimal reproduction repo and a trial run that you can easily check here.

Notes

  1. Runs triggered by closing pull requests (without merging them) work just fine. You can also check a trial run for that here.
  2. This is using cache@v2.
  3. GITHUB_REF in the failing case is master which is the main branch. In case of closing the pull request without merging, its in the format refs/pull/:prNumber/merge as mentioned in the documentation.

Most helpful comment

@metalsong Here's an example if you plan to go the s3 route - https://gist.github.com/scottjacobsen/ef7ccdf0ef48080a63e2fd4076d4e83f

All 3 comments

Having the exact same problem.
As a workaround I've considered to write simple action that saves cache to s3 bucket until this issue will fixed.

@metalsong Here's an example if you plan to go the s3 route - https://gist.github.com/scottjacobsen/ef7ccdf0ef48080a63e2fd4076d4e83f

I tried this (failed) workaround to open the workflow for all pull_request events, then check the event type within the jobs. An Action is triggered on pull request creation (and the jobs successfully skip), but another action is not triggered for its close/merge.

name: Workflow Name

on:
  pull_request:
    branches:
      - master

jobs:
  job-name:
    if: github.event.action == 'closed' && github.event.pull_request.merged == true

    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@master

Update: Ah, it's expected to not run on closed events. 馃う

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Lyeeedar picture Lyeeedar  路  5Comments

gladhorn picture gladhorn  路  4Comments

thisismydesign picture thisismydesign  路  4Comments

jwt27 picture jwt27  路  3Comments

wrightak picture wrightak  路  4Comments