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

fix: add necessary permissions to example workflow #31582

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,15 @@ This example workflow uses `gh-actions-cache` to delete up to 100 caches created
```yaml
name: cleanup caches by a branch
on:
pull_request:
pull_request_target:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
permissions:
actions: write

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

permissions is required regardless of the event if "Read and write permissions" are not selected in the settings(Settings > Actions > General > Actions permissions > Workflow permissions). In other words, it is not relevant to changing pull_request_target.
Therefore, I believe it is more appropriate to make this a separate pull request from #31322 .

This comment was marked as spam.

steps:
- name: Cleanup
run: |
Expand All @@ -369,7 +371,7 @@ jobs:
env:
GH_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
REPO: {% raw %}${{ github.repository }}{% endraw %}
BRANCH: refs/pull/{% raw %}${{ github.event.pull_request.number }}{% endraw %}/merge
BRANCH: {% raw %}${{ github.head_ref }}{% endraw %}
```

Alternatively, you can use the API to automatically list or delete all caches on your own cadence. For more information, see "[AUTOTITLE](/rest/actions/cache#about-the-cache-in-github-actions)."
Expand Down