Skip to content

Commit

Permalink
Merge pull request #1 from dokku/drone-plugin-support
Browse files Browse the repository at this point in the history
feat: add support for drone plugin env vars
  • Loading branch information
josegonzalez authored Jan 4, 2021
2 parents e460640 + 46d65cf commit 9da949e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bin/dokku-deploy
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#!/bin/sh -l
set -e

if [ -n "$PLUGIN_BRANCH" ]; then
export BRANCH="$PLUGIN_BRANCH"
fi
if [ -n "$PLUGIN_COMMAND" ]; then
export COMMAND="$PLUGIN_COMMAND"
fi
if [ -n "$PLUGIN_GIT_REMOTE_URL" ]; then
export GIT_REMOTE_URL="$PLUGIN_GIT_REMOTE_URL"
fi
if [ -n "$PLUGIN_GIT_PUSH_FLAGS" ]; then
export GIT_PUSH_FLAGS="$PLUGIN_GIT_PUSH_FLAGS"
fi
if [ -n "$PLUGIN_REVIEW_APP_NAME" ]; then
export REVIEW_APP_NAME="$PLUGIN_REVIEW_APP_NAME"
fi

setup-ssh

commit_sha="$(parse-ci-commit)"
Expand Down
4 changes: 4 additions & 0 deletions bin/parse-app-name
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh -l
set -e

if [ -n "$PLUGIN_GIT_REMOTE_URL" ]; then
export GIT_REMOTE_URL="$PLUGIN_GIT_REMOTE_URL"
fi

echo "$GIT_REMOTE_URL" | sed -e 's/.*\///'
3 changes: 3 additions & 0 deletions bin/parse-ci-branch-name
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -e
value="$CI_BRANCH_NAME"
if [ -n "$CI_BRANCH_NAME" ]; then
true
elif [ -n "$PLUGIN_CI_BRANCH_NAME" ]; then
# drone plugin
value="$PLUGIN_CI_BRANCH_NAME"
elif [ -n "$CIRCLE_BRANCH" ]; then
# circleci
value="$CIRCLE_BRANCH"
Expand Down
3 changes: 3 additions & 0 deletions bin/parse-ci-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -e
value="$CI_COMMIT"
if [ -n "$CI_COMMIT" ]; then
true
elif [ -n "$PLUGIN_CI_COMMIT" ]; then
# drone plugin
value="$PLUGIN_CI_COMMIT"
elif [ -n "$CIRCLE_SHA1" ]; then
# circleci
value="$CIRCLE_SHA1"
Expand Down
4 changes: 4 additions & 0 deletions bin/parse-ssh-host
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh -l
set -e

if [ -n "$PLUGIN_GIT_REMOTE_URL" ]; then
export GIT_REMOTE_URL="$PLUGIN_GIT_REMOTE_URL"
fi

echo "$GIT_REMOTE_URL" | sed -e 's/.*@//' -e 's/[:/].*//'
4 changes: 4 additions & 0 deletions bin/parse-ssh-port
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh -l
set -e

if [ -n "$PLUGIN_GIT_REMOTE_URL" ]; then
export GIT_REMOTE_URL="$PLUGIN_GIT_REMOTE_URL"
fi

ssh_port="$(echo "$GIT_REMOTE_URL" | sed -e 's/.*@//' -e 's/\/.*//' -ne 's/.*:\([0-9]*\)/\1/p')"
if [ -z "$ssh_port" ]; then
ssh_port=22
Expand Down
7 changes: 7 additions & 0 deletions bin/setup-ssh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/sh -l
set -e

if [ -n "$PLUGIN_SSH_HOST_KEY" ]; then
export SSH_HOST_KEY="$PLUGIN_SSH_HOST_KEY"
fi
if [ -n "$PLUGIN_SSH_PRIVATE_KEY" ]; then
export SSH_PRIVATE_KEY="$PLUGIN_SSH_PRIVATE_KEY"
fi

log-info "Setting up SSH Key"

mkdir -p /root/.ssh
Expand Down

0 comments on commit 9da949e

Please sign in to comment.