Automatic update local repository - linux

I'm having trouble creating some sort of automatic deployment function with Github
So, what I have is a repository on Github, and a local folder in my Ubuntu connected to that repository on Github, and what I want to achieve is, that everytime I upload/Add a new file to the repository on Github, I can somehow run a script that updates the local folder on my Ubuntu, with those new files stored in my repository on Github.
So to sum it up;
1.Upload new files to repo in Github
2.Run script on local Ubuntu machine
3. Newly uploaded files in repo in Github gets added to local folder on Ubuntu machine.
Is there anyways to achieve this? Thanks!

That seems to be a case for webhook, which comes with a constraint: your machine should be reachable from github.com.
If that is the case, you can setup a listener (for instance, alexandru/github-webhook-listener), which will detect JSON payload sent by GitHub on each push on your repository.
That local listener can then trigger a simple git pull in your local repository, updating its content that way.

Related

Updating local repo everytime original repo is changed

I have a project running on a remote server. I cloned it into the server to run. Problem is everytime I make a change to the code via git, I have to go into the remote server delete the folder and clone it once again. How can it automatically detect a change in the repo and update it?
You're looking for what's called continuous deployment|delivery.
Since you're using GitHub, you may want to look at GitHub Actions. This is one of many mechanisms that are available.
You can configure Actions to trigger various actions (including building, testing and deployment of your code [to the Digital Ocean droplet]) every time you make a commit.

jupyter notebooks not seen by GitHub

I have some local jupyter notebooks in my Linux virtual machine. I would like to make a repository with them on Github.
I downloaded Github Desktop as it seems easier than using command line.
The issue, is that when I select the file containing my notebooks (which I put on a share folder with my host OS (windows)) to add a repository, then on Github Desktop its still written '0 changed files', hence I can not commit to master. When I publish the repository, then its obviously empty :(.
Any suggestion would help me, I am new to Git.
Thank you very much!
You must add the files to a local clone of your GitHub repository.
Create a repository on GitHub with the name of the project.
Clone project to your desktop using GitHub Desktop.
Move all folder contents from your share folder on Windows to the cloned repository folder in the GitHub folder, probably inside of your Documents folder.
Follow the prompts on the GitHub Desktop client to add files to repository. Commit changes. And push the changes to GitHub's server.
You may find it easier to read the GitHub Desktop tutorial for more information on how to use GitHub. https://help.github.com/desktop/guides/contributing-to-projects/

How to automate pushing of code from local repository to remote bitbucket repository?

We have job that automatically generates a java code and pushes to a local repository in linux.
I need to find a solution on how to push the newly created java code from local repo to bitbucket repo automatically.
Each time the java code is generated, it will be with different folder name.
May it help you if you use branches?
You could create branches automatically and push them into bitbucket.

Node.js update via GitHub

So I am currently using node.js to make a Discord bot. I am switching the way things work however. The bot runs from my machine (computer), but I would like my friends to be able to work on it as well. Is there any way we can clone a GitHub repo into an existing folder, as to update the current BOT.js file we have?
The point of this is to have the bot auto update via github
You can create an empty Github repository, make sure to create it without any readme etc before you have made your first push.
Then using git, you initialize a git repo inside your current folder you are working out of, when you have done that, you can set a upstream to Github (w/ the repository URL you got for your newly created repository (on Github)), then just commit your files, push them to the Github repo master branch and you should be good to go.
Hope that helps!

How do I sync my local repo with my live website, backwards and forwards? Git

I have figured a way (using a few different tutorials) on how to push a local repo to a remote --bare repo that the uses a post-receive hook to push the contents to a live location.
So in brief explanation of my current situation
Make a change to a website locally
Use "git push live master"
Commit gets uploaded to remote repo
Remote repo pushes the contents to /home/unixuser/public_html
But say on this website there is an upload form where an admin can upload articles (on the live site), or where users can upload profile images. How would I sync my local repo with the new content in "public_html" as the repo is actually stored somewhere else on the server?
This sounds pretty simple but whenever I search for this I seem to get just the part on how to do post-receive scripts and how to upload, rather than the download part... or an over bloated explanation that leaves me confused. Is there a simplified answer to this question or am I possibly going about the whole thing the wrong way.
Any answers are appreciated, thanks!
Maybe you just need a copy script for whenever a new file is uploaded to copy it in your repo, commit + push that.
An other solution would be to use a second repository:
git-ignore the upload directory in your current repo. use a second repo which runs on the server, watching the upload directory - you just need to syncronize it to your local machine then. with git-ignore in the old repo, you could actually place the "upload"-repo inside the folder structure of the old repo (like it is on your server folder structure?)

Resources