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

Have cache invalidation not run on pull requests #688

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

gerrod3
Copy link
Collaborator

@gerrod3 gerrod3 commented Oct 22, 2024

No description provided.

@gerrod3
Copy link
Collaborator Author

gerrod3 commented Oct 22, 2024

Apparently the cache action command got merged into the gh CLI and the old plugin got deprecated yesterday! So updated to new command and fixed the passing of the token.

Comment on lines 54 to 55
permissions:
actions: write
Copy link
Member

Choose a reason for hiding this comment

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

Permission write on a PR workflow sounds wrong to me.
Or is "actions: write" special?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is suppose to be if I am understanding their docs correctly. The cache delete command is getting 403, so I think it needs more perms, so I am trying to add the minimum amount of extra perms. Not sure which permission I am missing.

https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions
https://docs.github.com/en/rest/authentication/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-actions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, I see that the token didn't get the write permission (https://github.com/pulp/pulp-oci-images/actions/runs/11463241947/job/31896626984#step:1:17), probably because this change is coming from a forked repository and default sec op is to not allow granting of write permissions. https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token. Maybe I should open this PR as a branch in this repository?

Copy link
Member

Choose a reason for hiding this comment

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

But this would still fail with any subsequent PR from a fork. I think we should never give write perms to a pr.

Can we just resort to not using the version from cache when we are in a PR workflow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Saw this comment after I merged the other one, so I updated this PR to add a check to prevent trying to invalidate the cache when ran in a pull request. This way PRs can take advantage of the cache if present, but will not affect the cache or need special perms.

@gerrod3 gerrod3 changed the title Fix cache invalidation command Have cache invalidation not run on pull requests Oct 22, 2024
@ggainey ggainey merged commit ccfbb55 into pulp:latest Oct 23, 2024
10 checks passed
@gerrod3 gerrod3 deleted the cache-clear-options branch October 24, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants