actions / stale

Marks issues and pull requests that have not had recent interaction
MIT License
1.34k stars 353 forks source link

Stale workflow fails to override cache. #1131

Open mshima opened 7 months ago

mshima commented 7 months ago

Description: We have a stale workflow: https://github.com/jhipster/generator-jhipster/blob/main/.github/workflows/stale.yml

At first run it successfully generates a cache entry.

After that, the cache is never updated and is reused, so cached entries are never analyzed again. See builds 599-605 at https://github.com/jhipster/generator-jhipster/actions/workflows/stale.yml

See 2 consecutive days have same cached issue numbers: https://github.com/jhipster/generator-jhipster/actions/runs/7689412024/job/20951825772 https://github.com/jhipster/generator-jhipster/actions/runs/7682085625/job/20936000418

The error reported is: Warning: Error delete _state: [403] Resource not accessible by integration

Are we missing a configuration? A permission maybe? There is no info in the docs.

Action version: v9

Platform:

Runner type:

Repro steps:
Links above.

Expected behavior: A new cache should be written at every run.

Actual behavior: New cache are not been overridden

HarithaVattikuti commented 7 months ago

Hello @mshima Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

csuermann commented 7 months ago

Looks like issues already processed in previous runs never get closed due to the cache.

.github/workflows/stale.yaml:

name: 'Close stale issues'
on:
  workflow_dispatch:
  schedule:
    - cron: '30 1 * * *'
permissions:
  issues: write

jobs:
  stale:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/stale@v9
        with:
          stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.'
          days-before-stale: 30
          days-before-close: 5
Run actions/stale@v9
Cache Size: ~0 MB (307 B)
/usr/bin/tar -xf /home/runner/work/_temp/f4844f75-67b0-4546-8244-42b90d2f9d54/cache.tzst -P -C /home/runner/work/xxx --use-compress-program unzstd
Cache restored successfully
state: restored with info about 12 issue(s)
Starting the stale action process...
Processing the batch of issues  #1  containing  11  issues...
[#239] Issue #239
[#238] Issue #238
[#237] Issue #237
[#235] Issue #235
[#234] Issue #234
[#231]            issue skipped due being processed during the previous run
[#229]            issue skipped due being processed during the previous run
[#227]            issue skipped due being processed during the previous run
[#222]            issue skipped due being processed during the previous run
[#221]            issue skipped due being processed during the previous run
[#219]            issue skipped due being processed during the previous run
Batch  #1  processed.
No more issues found to process. Exiting...
Statistics:
Processed issues: 5
Fetched items: 11
Operations performed: 2
Github API rate used: 2
Github API rate remaining: 997; reset at: Wed Feb 07 2024 02:59:48 GMT+0000 (Coordinated Universal Time)
state: persisting info about 0 issue(s)
Warning: Error delete _state: [403] Resource not accessible by integration
the state will be removed
Received 307 of 307 (100.0%), 0.0 MBs/sec
mshima commented 7 months ago

As workaround:

anomiex commented 6 months ago

I think the docs are missing that the actions: write permission is needed.

I saw the "Error delete _state: [403] Resource not accessible by integration" error here in a test repo while trying to reproduce a different issue, and based on the docs for the API used I added that permission and the error went away.