Compare commits
4 Commits
cd9a3ea255
...
cc7d62d975
| Author | SHA1 | Date | |
|---|---|---|---|
| cc7d62d975 | |||
| d58f26d49c | |||
| ef7e5956ed | |||
| acd0572d6b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
|
config.py
|
||||||
7
config.example.py
Normal file
7
config.example.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
portainer_url = 'https://portainer.dorfsvald.net'
|
||||||
|
portainer_access_token = 'example_access_token'
|
||||||
|
portainer_compose_dir = '/absolute/path/to/portainer-data/compose'
|
||||||
|
git_repositories = [
|
||||||
|
'path/to/a/git/repository',
|
||||||
|
'path/to/another/git/repo'
|
||||||
|
]
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
access_token = 'example_access_token'
|
|
||||||
portainer_compose_dir = '/absolute/path/to/portainer-data/compose'
|
|
||||||
@@ -5,6 +5,6 @@ set -e
|
|||||||
PROJECT_NAME=$1
|
PROJECT_NAME=$1
|
||||||
COMPOSE_FILE=$2
|
COMPOSE_FILE=$2
|
||||||
|
|
||||||
docker-compose -p $PROJECT_NAME -f $COMPOSE_FILE stop
|
docker compose -p $PROJECT_NAME -f $COMPOSE_FILE stop
|
||||||
docker-compose -p $PROJECT_NAME -f $COMPOSE_FILE pull
|
docker compose -p $PROJECT_NAME -f $COMPOSE_FILE pull
|
||||||
docker-compose -p $PROJECT_NAME -f $COMPOSE_FILE up -d
|
docker compose -p $PROJECT_NAME -f $COMPOSE_FILE up -d
|
||||||
|
|||||||
8
main.py
8
main.py
@@ -7,6 +7,12 @@ import config
|
|||||||
|
|
||||||
DOCKER_COMPOSE_PATH = config.portainer_compose_dir + '/{}/docker-compose.yml'
|
DOCKER_COMPOSE_PATH = config.portainer_compose_dir + '/{}/docker-compose.yml'
|
||||||
BASH_COMPANION_SCRIPT = os.getcwd() + '/docker_updater.sh'
|
BASH_COMPANION_SCRIPT = os.getcwd() + '/docker_updater.sh'
|
||||||
|
REPO_UPDATER_SCRIPT = os.getcwd() + '/update_repo.sh'
|
||||||
|
|
||||||
|
|
||||||
|
def update_repositories():
|
||||||
|
for repo_path in config.git_repositories:
|
||||||
|
os.system(f"{REPO_UPDATER_SCRIPT} {repo_path}")
|
||||||
|
|
||||||
|
|
||||||
def update_stack(stack):
|
def update_stack(stack):
|
||||||
@@ -21,7 +27,7 @@ if __name__ == '__main__':
|
|||||||
"X-API-Key": config.access_token
|
"X-API-Key": config.access_token
|
||||||
}
|
}
|
||||||
|
|
||||||
api_url = "https://portainer.dorfsvald.net/api/stacks"
|
api_url = f"{config.portainer_url}/api/stacks"
|
||||||
response = requests.get(api_url, headers=headers)
|
response = requests.get(api_url, headers=headers)
|
||||||
stack_list = response.json()
|
stack_list = response.json()
|
||||||
|
|
||||||
|
|||||||
6
update_repos.sh
Executable file
6
update_repos.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
REPO_PATH=$1
|
||||||
|
|
||||||
|
git -C $REPO_PATH fetch --tags
|
||||||
|
LAST_HASH=`git -C $REPO_PATH rev-list --tags --max-count=1`
|
||||||
|
LAST_TAG=`git -C $REPO_PATH describe --tags $LAST_HASH`
|
||||||
|
git -C $REPO_PATH checkout $LAST_TAG
|
||||||
Reference in New Issue
Block a user