Updated How to autocommit config changes to github? (markdown)
@@ -1,15 +1,13 @@
|
||||
# **💡 How to autocommit config changes to github?**
|
||||
|
||||
**On this wiki page i will briefly explain how to create a G-Code macro in Klipper for creating commits and pushing them to github.\
|
||||
This will enable you to backup your printers configuration with a simple g-code macro and/or the click of a single button.**
|
||||
|
||||
## **📢 Disclaimer:**
|
||||
## **Disclaimer:**
|
||||
The usual disclaimer also applies here. Usage of this guide happens at your own risk.\
|
||||
I will not be responsible for any issues that arise during or after this procedure.
|
||||
|
||||
---
|
||||
|
||||
## **❓ What do we need:**
|
||||
## **What do we need:**
|
||||
- Github account
|
||||
- Github repository
|
||||
- G-Code Shell Command extension
|
||||
@@ -19,7 +17,7 @@ I will not be responsible for any issues that arise during or after this procedu
|
||||
|
||||
---
|
||||
|
||||
## **🟢 Let's start...**
|
||||
## **Let's start...**
|
||||
I find it really usefull to always commit my config changes to a dedicated github repository. Since i am Mainsail/Fluidd, i need to have a seperate folder for my config-files anyways to make use of their config editor.\
|
||||
I picked the same name for the configuration folder and the github repository: `klipper_config`.
|
||||
This makes me able to git clone the whole set of my configuration files in one go, and push them to github to make a backup.
|
||||
@@ -30,7 +28,7 @@ Doing this by hand is a possible way. It's not big of a deal and if you are fami
|
||||
|
||||
---
|
||||
|
||||
## **🔵 Step 1️:**
|
||||
## **Step 1️:**
|
||||
First of all we need to install the G-Code Shell Command extension for Klipper.\
|
||||
Please have a look at the [G-Code Shell Command Extension Doc](https://github.com/th33xitus/kiauh/blob/master/docs/gcode_shell_command.md).\
|
||||
You can either do this by copying the `gcode_shell_command.py` from the KIAUH resources folder to `klipper/klippy/extras`.\
|
||||
@@ -41,7 +39,7 @@ After we installed the G-Code Shell Command extension, we are able to run shell
|
||||
|
||||
---
|
||||
|
||||
## **🟣 Step 2:**
|
||||
## **Step 2:**
|
||||
Now we need a suitable shell script which does all the tasks we usually need to do manually when commiting and pushing to github.\
|
||||
An example script can be seen below. Feel free to use it or write your own.\
|
||||
Then upload the script to your Raspberry Pi.
|
||||
@@ -119,21 +117,24 @@ Example of how a commit message could look like:\
|
||||
|
||||
---
|
||||
|
||||
## **🟡 Step 3:**
|
||||
## **Step 3:**
|
||||
We do not want any username or password prompts from github because we can't react to them.\
|
||||
Therefore shell command and macro needs to be able to run without any further interaction.
|
||||
That means we need to make git not ask for user credentials, otherwise all of this will not work.
|
||||
That means we need to make git not ask for our user credentials, otherwise all of this will not work.
|
||||
|
||||
There are different ways on how to achive that, i suggest taking a look here and pick the method you prefere:\
|
||||
https://www.freecodecamp.org/news/how-to-fix-git-always-asking-for-user-credentials
|
||||
|
||||
Personally, i went with sending a `git config --global credential.helper store`.\
|
||||
In this case i needed to make one push manually to make git prompt for username and password so it can save those.
|
||||
I went with `git config --global credential.helper store`.\
|
||||
In this case i need manually push one time to make git prompt for username and password.
|
||||
For a while now, Github does not allow the use of a regular password anymore.
|
||||
Now you need to enter a so called personal access token. You have to create one first here: https://github.com/settings/tokens \
|
||||
The token basically represents the password.
|
||||
|
||||
After we made sure we can commit and push to github without having to re-enter username and password all the time we are almost done.
|
||||
After we made sure we can commit and push to github, without having to re-enter username and token all the time, we are almost done.
|
||||
|
||||
---
|
||||
|
||||
## **🔴 Step 4:**
|
||||
## **Step 4:**
|
||||
The last step is to create a shell command and a G-Code macro.
|
||||
Here is an example on how those could look:
|
||||
```c++
|
||||
@@ -157,7 +158,7 @@ Let's say the script is located in your home directory, `command` has to look so
|
||||
The timeout of 30 seconds is just an example but i suggest not to use a way too short timeout.\
|
||||
Otherwise the execution of the script will be stopped forcefully before it even completes.
|
||||
|
||||
## **🟤 Step 5:**
|
||||
## **Step 5:**
|
||||
You are now able to call the G-Code macro you created and backup your config files with a single command.\
|
||||
Or if you use Mainsail like me even with a single click of a button:
|
||||
| Macro button in Mainsail: | Console output after sending: |
|
||||
@@ -166,7 +167,7 @@ Or if you use Mainsail like me even with a single click of a button:
|
||||
|
||||
---
|
||||
|
||||
## **🏁 Done!**
|
||||
## **Done!**
|
||||
Congratulations!\
|
||||
You can now backup your configuration files with ease!
|
||||
|
||||
|
||||
Reference in New Issue
Block a user