How to exclude workflow files from a forked repo when submitting a pull request?

I’ve forked a repo and added some custom workflow files in my .github/workflows folder. Now I want to submit a pull request to the original repo, but I don’t want these workflow files to be included. They are specific to my setup and rely on secrets that the base repo does not have.

If I submit a PR as usual, everything will be included, and I worry that the base repo’s Actions might try to run these workflows and fail due to missing secrets. I considered using .gitignore to exclude the workflow folder, but I’ve learned that this approach is not recommended.

Is there a recommended way to keep my workflow files separate from the PR, allowing me to contribute my other changes without affecting the base repo’s Actions? Any advice would be greatly appreciated. Thanks!

I’ve faced this issue before, and here’s what worked for me: Create a separate branch for your custom workflows. Keep your main branch clean and in sync with the original repo. When you’re ready to submit a PR, make sure you’re on the main branch, then create a new branch specifically for your changes. This way, you can make your modifications without including the custom workflow files.

Before submitting the PR, double-check that your workflow files aren’t included in the changes. If they are, you can use ‘git reset’ to remove them from the commit history of your PR branch. Just be careful not to reset any changes you actually want to keep.

Remember to clearly explain in your PR description that you’ve intentionally excluded your custom workflows. This helps the maintainers understand your approach and avoids any confusion. Good luck with your contribution!

One effective approach to handle this situation is to use Git’s sparse-checkout feature, which allows you to selectively choose the files and directories included in your working directory. I suggest you clone the original repository, set up sparse-checkout to exclude the .github/workflows directory, then make your changes and commit them before pushing to your fork and creating the pull request. Alternatively, you may create a separate branch for your custom workflows while keeping your main branch in sync with the original repository. It is important to communicate any specific setup details in your PR description.

hey, i’ve dealt with this before. u could try using git cherry-pick to selectively apply commits, excluding ur workflow changes. Another option is creating a separate branch for ur custom workflows and only merging the relevant changes. just remember to clearly explain ur approach in the PR description so the maintainers understand what ur doing

You might consider using Git’s ‘git stash’ command to temporarily set aside your workflow files before creating the pull request. First, stash your workflow files with the command ‘git stash push -m “Custom workflows” .github/workflows/’ then create a new branch for your pull request using ‘git checkout -b pr-branch’. After making your changes and committing them, push your branch and create the pull request. Once the PR is merged, you can reapply the stashed changes with ‘git stash pop’. Remember to mention in your PR description that custom workflow files have been excluded to maintain a clean contribution.