diff --git a/Dockerfile b/Dockerfile index b6b7879..75c80e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,8 @@ FROM alpine:latest -COPY --from=git.coopcloud.tech/coop-cloud/abra:dev /abra /usr/bin/abra +RUN apk add --no-cache bash openssh + +COPY --from=git.coopcloud.tech/coop-cloud/abra:dev /abra /root/.local/bin/abra COPY plugin.sh /plugin/plugin.sh diff --git a/README.md b/README.md index 2ee6032..568c553 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,6 @@ Use [`abra`](https://git.autonomic.zone/coop-cloud/abra) as a [Drone plugin](htt ### Required (no default) - **command**: The command to run (passed to `abra` executable) -- **deploy_key**: SSH private key part for running `git push` related commands - -### Optional - -- **recipe_branch** (default: `main`): The target branch to use for recipe release `git push` operations ## Example @@ -25,13 +20,11 @@ steps: - name: release a new version image: thecoopcloud/drone-abra:latest settings: - command: recipe matrix-synapse release - deploy_key: - from_secret: abra_bot_deploy_key + command: catalogue generate ``` ## Publishing The version can be bumped in the [.drone.yml](./.drone.yml) file. We're sticking with `latest` as we iterate on the code right now. -If you push a commit to master, the [Drone config](./.drone.yml) will publish to [Docker Hub](https://hub.docker.com/r/thecoopcloud/drone-abra). +If you push a commit to main, the [Drone config](./.drone.yml) will publish to [Docker Hub](https://hub.docker.com/r/thecoopcloud/drone-abra). diff --git a/plugin.sh b/plugin.sh index b7efd33..08ab942 100755 --- a/plugin.sh +++ b/plugin.sh @@ -4,49 +4,20 @@ set -e ABRA=/root/.local/bin/abra -PLUGIN_BRANCH=${PLUGIN_BRANCH:-main} PLUGIN_HOST=${PLUGIN_HOST:-git.coopcloud.tech} PLUGIN_PORT=${PLUGIN_PORT:-2222} -checkout_main_or_master() { - git checkout main > /dev/null 2>&1 || git checkout master > /dev/null 2>&1 -} - -load_deploy_key() { - echo "--- start ssh key load ---" - mkdir -p "$HOME/.ssh/" - ssh-keyscan -p "$PLUGIN_PORT" "$PLUGIN_HOST" > "$HOME/.ssh/known_hosts" - - # shellcheck disable=SC2046,SC2006 - eval `ssh-agent` - echo "$PLUGIN_DEPLOY_KEY" | ssh-add - - echo "--- end ssh key load ---" -} - output_versions(){ echo "--- start versions" - $ABRA version + $ABRA -v echo "--- end versions" } run_abra_cmd() { echo "--- start command ---" - if [[ $PLUGIN_COMMAND == *"release"* ]]; then - echo "Detected release command, attempting to detect recipe now..." - recipe=$(echo "$PLUGIN_COMMAND" | cut -d' ' -f2) - echo "Automagically detected $recipe as desired recipe repository, cloning now..." - - git clone "https://${PLUGIN_HOST}/coop-cloud/$recipe.git" "/root/.abra/apps/$recipe" - cd "/root/.abra/apps/$recipe" && checkout_main_or_master && \ - git remote rm origin && \ - git remote add origin "ssh://git@${PLUGIN_HOST}:${PLUGIN_PORT}/coop-cloud/$recipe.git" - - git push --set-upstream origin "$PLUGIN_BRANCH" - fi - # shellcheck disable=SC2086 - $ABRA --debug --no-prompt $PLUGIN_COMMAND + $ABRA $PLUGIN_COMMAND echo "--- end command ---" } @@ -54,7 +25,6 @@ run_abra_cmd() { run_plugin() { echo "--- start drone-abra ---" output_versions - load_deploy_key run_abra_cmd echo "--- end drone-abra ---" }