Add exec_pre option
continuous-integration/drone/push Build is passing Details

This commit is contained in:
3wc 2024-01-22 22:32:16 -03:00
parent d85572856b
commit 7b35bd30b3
2 changed files with 7 additions and 0 deletions

View File

@ -19,6 +19,7 @@
- **port** (default: `222`): SSH port to connect to
- **user** (default: `drone`): System user to connect via SSH with
- **exec** (default: none): Run a command in the container after copying
- **exec_pre** (default: none): Run a command in the container before copying
### Makes me sad they exist

View File

@ -51,6 +51,12 @@ run_docker_cp() {
CD="-C $PLUGIN_CHDIR"
fi
echo "--- start exec_pre ---"
if [ -n "$PLUGIN_EXEC_PRE" ]; then
docker -H "$REMOTE_DOCKER_HOST" exec "$CONTAINER" sh -c "mkdir -p /root/.ssh && echo \"$PLUGIN_DEPLOY_KEY\" > /root/.ssh/id_rsa && chmod -R 600 /root/.ssh && $PLUGIN_EXEC_PRE"
fi
echo "--- end exec ---"
echo "Copying $PLUGIN_SOURCE"
# shellcheck disable=SC2086
tar cf - $CD $PLUGIN_SOURCE | docker -H "$REMOTE_DOCKER_HOST" cp - $CONTAINER:$PLUGIN_DEST