Compare commits

...

3 Commits

Author SHA1 Message Date
9b5a45290a Improving logging further 2023-12-01 20:40:10 +01:00
a64fc40a16 Merge remote-tracking branch 'origin/master' 2023-12-01 20:34:47 +01:00
3b79e59076 Adding quotes in bash 2023-11-24 21:04:05 +01:00
3 changed files with 17 additions and 11 deletions

View File

@@ -5,6 +5,6 @@ set -e
PROJECT_NAME=$1
COMPOSE_FILE=$2
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 up -d
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" up -d

14
main.py
View File

@@ -102,23 +102,29 @@ if __name__ == '__main__':
client = PortainerClient(portainer_url=config.portainer_url, access_token=config.access_token)
for stack in client.list_stacks():
endpoint = stack['EndpointId']
stack_name = stack['Name']
if stack['Status'] == 1:
endpoint = stack['EndpointId']
stack_name = stack['Name']
print(f"Checking {stack_name} for updates.")
containers = client.list_stack_containers(endpoint, stack_name)
an_image_was_updated = False
for c in containers:
this_image_was_updated = client.update_image(endpoint, c['Image'])
if this_image_was_updated:
print(f"{c['Image']} was updated")
print(f"{c['Image']} was updated.")
an_image_was_updated = True
if an_image_was_updated:
print(f"Restarting {stack_name}")
print(f"{stack_name} was updated. Restarting...")
if endpoint == 2 and stack_name in ('portainer', 'traefik'):
update_local_stack(stack)
else:
client.upgrade_stack(stack)
print(f"{stack_name} restarted.")
else:
print(f"{stack_name} is up to date. Skipping.")
os.system('docker image prune -fa')

View File

@@ -1,6 +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
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"