Open bugy opened 3 years ago
Hi there!
I have something similar configured on my end, not sure if this helps, but maybe it can serve as a workaround for the time being.
In my implementation, I find that I sometimes need to get code to the app faster than redeploying a new docker image. To this extent i've configured a code refresh script that handles one-way synch(gitlab to scriptserver).
Runner:
{ "name": "\ud83d\udcbbAdmin Code Refresh", "script_path": "/Script-Server/conf/scripts/code_refresh.sh", "working_directory": "/", "description": "\n__Code refresh__\nThis script will pull data from the following code repository:\n__[Script-Server]Changes will be reverted on container restart, this is for troubleshooting only!", "requires_terminal": true, "allowed_users": [ "@blabla"], "group": "Administration", "parameters": [ { "name": "Branch", "required": true, "type": "list", "description": "Enter branch you want to pull from", "default": "master", "values": [ "master", "development" ] }, { "name": "Folder", "required": true, "type": "list", "description": "Which folder would you like to synch?", "default": "scripts", "values": [ "scripts", "runners" ] } ] }
Actual script, sh:
`#!/bin/sh set -ue . /Script-Server/conf/scripts/reusables.sh
BRANCH=${1} FOLDER=${2} GIT_REPO="git@myrepo_lorem_ipsum/script-server.git"
git archive --remote=''$GIT_REPO'' ${BRANCH} Script-Server/conf/${FOLDER} --format=tar.gz > /tmp/code_refresh.tar.gz
if [ -s "/tmp/code_refresh.tar.gz" ];then printf "$green" "Code succesfully pulled, extracting archive!" rm -rf /Script-Server/conf/${FOLDER} tar -xvzf /tmp/code_refresh.tar.gz -C /Script-Server/conf/ --strip-components 2 rm -rf /tmp/code_refresh.tar.gz chmod -R +x /Script-Server/conf/scripts/ printf "\n" else printf "$red" "ERROR, something went wrong, could not pull code, please check archive contents" exit 0 fi`
It is the only lightweight way of pulling specific folders off git i've found, without messing with arcane terms to me like git sparse checkout:D I am using "git archive --remote"
Hope this helps!
Thanks! I added the link to your comment into the wiki: https://github.com/bugy/script-server/wiki/Store-config-in-Git
I'll keep this ticket open to make this a feature of script server one day :)
Thanks very much, keep up the great work! :D
This a great idea! Here is another script to do it:
Since the script-server allows to edit config with the UI, it's better to have a two way update script ! Here is my own git update script, which is two ways + extra features: https://github.com/tristanlatr/autogit It's can do bulk update across multiple repos with any ssh keys :D and more merge options. A template config file is here: https://github.com/bugy/script-server/issues/309 The script it's well tested! I've been using it for years now.
I think a scheduled task should be able to maintain the repo up to date?
No idea how it could be implemented, but there should be a possibility to pull configuration changes from git and push them if there are any changes