Skip to content

'cleanup caches' example workflow is wrong and harmful! #23600

@andreasabel

Description

@andreasabel

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries

Lifted from:

The workflow that is supposed to delete PR-caches deletes caches from master/base branch:

pull_request:
types:
- closed
workflow_dispatch:
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: {% data reusables.actions.action-checkout %}
- name: Cleanup
run: |
gh extension install actions/gh-actions-cache
REPO={% raw %}${{ github.repository }}{% endraw %}
BRANCH={% raw %}${{ github.ref }}{% endraw %}

This looks logical, but seems to be wrong. If invoked by a closing PR, BRANCH ends up to be the base branch, e.g. master. This job will then remove exactly the wrong caches.

Should be fixed immediately by some knowledgeable person. Or at least add the disclaimer I suggested in the PR.

Evidence here: https://github.com/agda/agda/actions/runs/4025940394/jobs/6919801891#step:3:5
(Note: these logs will be removed by github after some time.)

What part(s) of the article would you like to see updated?

See above.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    actionsThis issue or pull request should be reviewed by the docs actions teamcontentThis issue or pull request belongs to the Docs Content teamwaiting for reviewIssue/PR is waiting for a writer's review

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions