Access Files From Git Shared Repository To Other Repositories
Updating similar code or any similar changes in multiple git repositories are not a good practice. If you are using more than one repository and performing any code change or updating files in each repository are confusing and time-consuming work.
To do such kind of changes you need to remember and look for the right repositories in which changes required.
This kind of mind storming work can be avoided by using shared git repository and access the files from there to other repositories.
Follow the steps below to access files from git shared repository to other repositories –
- Create a common repository and push the files in the repository.
- Go to settings in shared repository and click on Deploy keys.
- Generate public and private key in your system. You can follow online help for how to generate public and private key.
- Give any name and paste your public key in Key section of Deploy keys.
- Now go to the main repository where you want to access the files.
- Go to settings click on Secrets key.
- Give any name and pasted the private key.
- Add the below code in action file in the main repository. If you are not using action file, then created one action file under .github/workflows/actions.yml
Now whenever you execute or build in main repository the shared repository files will be called and executed.
Leave a Reply