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 #3202 with conditional workflow #3207

Merged
merged 15 commits into from
Oct 18, 2023
Merged

Conversation

loftwah
Copy link
Member

@loftwah loftwah commented Oct 17, 2023

Related issue

#3202

What changes does this PR do?

Adds a conditional workflow

Screenshots (If any)

Questions

@loftwah
Copy link
Member Author

loftwah commented Oct 17, 2023

If you add a secret called EDDIEHUB_PAT with the appropriate permissions this should work.

This GitHub Actions workflow is designed to automatically comment on pull requests. It can work on both the main repository and forked repositories. The workflow uses two tokens: a Personal Access Token (PAT) named EDDIEHUB_PAT for the main repository, and the default GITHUB_TOKEN for forks or if the PAT is not set.

  1. The workflow is triggered on pull request events and manual workflow dispatches.

  2. An initial step sets an environment variable PAT_EXISTS to indicate whether EDDIEHUB_PAT is available.

  3. Two conditional steps follow:

    • If the workflow is running in the main repository and PAT_EXISTS is true, it uses the PAT to comment on the pull request.
    • Otherwise, it uses the default GITHUB_TOKEN to comment.

@loftwah
Copy link
Member Author

loftwah commented Oct 17, 2023

It works in my repo with my GH token.
image

@dan-mba
Copy link
Member

dan-mba commented Oct 17, 2023

This GitHub Actions workflow is designed to automatically comment on pull requests.

Because of the way actions run on pull_request for forks, they always run in the context of the forked repo. They don't have access to secrets from the main repo.

The trigger needs to be changed to pull_request_target and it will work without adding a PAT.

See the note about forked repos in the permissions section

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.

None yet

3 participants