How do I set up a Raspberry Pi 3 B+ to Auto Deploy updates to a private Github Repo?

Viewed 4887

I bought a Pi 3 B+ and would like to have it auto clone/deploy new pushes (from a different machine) from a private github repo. I was just wondering how I would do that. I know I need a github web hook but I have no clue where to start. The Pi is going to be in a place I dont want to get to very often to update my code so this would make everything so much easier. Thanks

3 Answers
  1. You need to clone your repository to your Raspberry Pi

    git clone git@github.com:your-username/your-repo-name.git

  2. Then before starting your script you just pull new version from github to your local repository and run updated script git pull origin master

example of starting script:

#!/bin/bash
cd /your-local-repository-path/
git pull origin master
python your-script.py &

Dont forget make start script executable sudo chmod 755 starting-script.sh

Then you can run your starting script /.starting-script.sh

It shoud pull latest version of remote repository to your local repository before running.

Hope it helps you.

I figured it out. I just ended up creating a local Jenkins server and used a plugin to that would auto pull the repo from a webhook. to set up the webhook I made the local Jenkins server available to the internet so that the plugin would catch the webhook.

Maybe this could help out someone else.

Git-Auto-Deploy consists of a small HTTP server that listens for Webhook requests sent from GitHub, GitLab or Bitbucket servers. This application allows you to continuously and automatically deploy your projects each time you push new commits to your repository

Related