Support custom actions
This commit is contained in:
@ -52,6 +52,9 @@ stack_down() {
|
||||
# It is not at all necessary to transfer and unpack the workspace here, but I'll do it anyway for simplicity's sake.
|
||||
echo "set -e ; log() { echo '>> [remote]' \$@ ; } ; cleanup() { log 'Removing workspace...'; rm -rf \"\$HOME/workspace\" ; } ; log 'Creating workspace directory...' ; mkdir -p \"\$HOME/workspace/$DOCKER_COMPOSE_PROJECT\" ; trap cleanup EXIT ; log 'Unpacking workspace...' ; tar -C \"\$HOME/workspace/$DOCKER_COMPOSE_PROJECT\" -xjv ; log 'Launching docker stack rm...' ; cd \"\$HOME/workspace/$DOCKER_COMPOSE_PROJECT\" ; docker stack rm \"$DOCKER_COMPOSE_PROJECT\""
|
||||
}
|
||||
custom_action() {
|
||||
echo "set -e ; log() { echo '>> [remote]' \$@ ; } ; cleanup() { log 'Removing workspace...'; rm -rf \"\$HOME/workspace\" ; } ; log 'Creating workspace directory...' ; mkdir -p \"\$HOME/workspace\" ; trap cleanup EXIT ; log 'Unpacking workspace...' ; tar -C \"\$HOME/workspace\" -xjv ; log 'Launching docker compose...' ; cd \"\$HOME/workspace\" ; docker compose -f \"$DOCKER_COMPOSE_FILENAME\" -p \"$DOCKER_COMPOSE_PROJECT\" pull ; docker compose -f \"$DOCKER_COMPOSE_FILENAME\" -p \"$DOCKER_COMPOSE_PROJECT\" run --rm \"$CUSTOM_ACTION_TARGET\" \"$CUSTOM_ACTION\""
|
||||
}
|
||||
|
||||
deploy() {
|
||||
local remote_command
|
||||
@ -67,9 +70,19 @@ deploy() {
|
||||
if [ "$DEPLOY_ACTION" == "up" ]; then
|
||||
log "Deploying docker compose project ${DOCKER_COMPOSE_PROJECT}."
|
||||
remote_command=$(compose_up)
|
||||
else
|
||||
elif [ "$DEPLOY_ACTION" == "down" ]; then
|
||||
log "Removing docker compose project ${DOCKER_COMPOSE_PROJECT}."
|
||||
remote_command=$(compose_down)
|
||||
elif [ "$DEPLOY_ACTION" == "custom" ]; then
|
||||
if [ -z "$CUSTOM_ACTION" ] || [ -z "$CUSTOM_ACTION_TARGET" ]; then
|
||||
echo "ERROR: You must set custom_container_action and custom_container_action_target"
|
||||
exit 1
|
||||
fi
|
||||
log "Running custom action on project ${DOCKER_COMPOSE_PROJECT}:"
|
||||
log "Action: ${CUSTOM_ACTION}"
|
||||
log "Target: ${CUSTOM_ACTION_TARGET}"
|
||||
remote_command=$(custom_action)
|
||||
|
||||
fi
|
||||
fi
|
||||
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
|
||||
|
||||
Reference in New Issue
Block a user