-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Add option to prevent step from running in forks #153
Comments
There is a quick workaround like the following: - name: Deploy to GitHub Pages
if: github.event.repository.fork == false
uses: peaceiris/actions-gh-pages@v3 # v3.5.2
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
# publish_branch: gh-pages # default
publish_dir: ./path_to_dir The deployment on a fork will skip but it is better and friendly for users to detect fork status by this action internally. We should consider whether this action is running on a fork, or not. When we use the - name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3 # v3.5.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./path_to_dir This setting works on a fork not only an original repository. Checking whether this action runs on a fork is needed for only Besides, disabling deployment on a fork by default is not good because some users are using this action on their fork for their deployment. (GitHub's fork feature is not for only pull requests.)
Here is a simple example to get a repository metadata about fork status in action side. import {context} from '@actions/github';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isForkRepository = (context.payload as any).repository.fork === 'true';
core.info(`isForkRepository: ${isForkRepository}`);
if (isForkRepository) {
core.info('[INFO] This action runs on a fork');
// skip deployment
} else {
// do usual stuff
}
Thank you. I want more time to think about this specification. |
Thanks for the detailed response. What do you think of adding another parameter (for example
Essentially, the action will be skipped if the following boolean expression is true: skip_on_forks && (cname || !github_token). This would solve the problem you mentioned for users that want to maintain a separate fork (instead of PRs) while providing a way to skip the action for those who just want to send a PR. Thoughts? |
Thank you for suggesting I have one idea that does not need to set an option on an upstream repo, has no breaking change to skip deployment on the forks. How about skipping deployment on forks when the For users who want to follow their upstream and deploy their own site, this action can print a warning message (e.g. |
One of the reasons why I proposed adding another option was that it makes it obvious when looking at the yml file that something different happens on forks, but after hearing your latest proposal I like it better. Is there something else you want to change or think about before moving into implementation? |
See the Makefile, test, and create your commit on a Docker container. |
Did you change your mind on the |
In the case of adding the |
I see, why do you prefer that solution over the one you argued for before?
|
That comes from the name of the My suggestion "skipping deployment on forks when the deploy_key or personal_token is set and it is empty" is a solution without adding a new option. |
My suggestion is based on this previous work nwtgck/actions-netlify#33 |
I apologize to you for my lack of clarity in this comment. #153 (comment)
My suggestion does not need any new options. We can implement our demand without adding a new option like OK. I will implement it and show you my idea. |
I opened #156 and released |
Wow great work @peaceiris Amazed by how well maintained this Action is. |
I apologise, I think I didn't explain myself well before, as I did understand both your solution and the
In any case, everything seems to be solved now and there's already an implementation which I think is perfect (I don't understand why there are several commits adding and removing |
I want to say again, thank you @corollari for suggesting this issue. And I am sorry for confusing you in this thread...
When I read this description, I thought it is good to add the new option
Thank you. I will merge #156, release it as
This action and my other actions do not provide the branch execution. I add the |
* fix: skip on forks * chore(release): 3.5.4-6 Close #153
v3.5.4 has been released and the v3 tag updated. Thank you. |
Thanks! Will start watching the repo and help whenever I can 👍 |
Any idea why I get this error with v3.7.3 specially since the repository that I'm using isn't a fork? If I add |
@fharper I cannot understand your problem without your log and settings. You can ask about it at the Discussions · peaceiris/actions-gh-pages first and provide the details. |
@peaceiris my bad! Thanks, I'll share it in the GitHub Discussions. |
Is your feature request related to a problem? Please describe.
When other users fork my repositories this action always fails on their forks because either they don't have the proper secret set up or the cname is already taken (by my upstream repo), this is slightly confusing and it requires me and the users to go to the build page for every build run in order to check if it's this action the one failing or if it's something else.
Describe the solution you'd like
It'd be great if we could toggle an option that would disable this specific action when it's being run in forks.
Describe alternatives you've considered
I can check the origin repository inside an if clause and only run the action if the origin is equal to the upstream name, but while this works it's a bit messy because it requires setting the repository id every time a workflow is set up.
Another alternative would be to just enable allow_failures, but then I wouldn't get alerted when the action fails to deploy the page correctly on the upstream repo.
Overall I don't know if this is something easily doable (the only solution I can think of for detecting if a repo is a fork involves querying github's api) or common enough to warrant it being included as an option.
In any case, I'm willing to implement a solution and create a PR if we manage to come up with an elegant solution to this problem.
The text was updated successfully, but these errors were encountered: