Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vortex/docs/content/development/variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ The list below is automatically generated with [Shellvar](https://github.com/ale
| <a id="vortex_deploy_lagoon_pr_head"></a>`VORTEX_DEPLOY_LAGOON_PR_HEAD` | The PR head branch to deploy. | `${VORTEX_DEPLOY_PR_HEAD}` | `scripts/vortex/deploy-lagoon.sh` |
| <a id="vortex_deploy_lagoon_ssh_file"></a>`VORTEX_DEPLOY_LAGOON_SSH_FILE` | Default SSH file used if custom fingerprint is not provided. | `${HOME}/.ssh/id_rsa` | `scripts/vortex/deploy-lagoon.sh` |
| <a id="vortex_deploy_lagoon_ssh_fingerprint"></a>`VORTEX_DEPLOY_LAGOON_SSH_FINGERPRINT` | SSH key fingerprint used to connect to remote. If not used, the currently loaded default SSH key (the key used for code checkout) will be used or deployment will fail with an error if the default SSH key is not loaded. In most cases, the default SSH key does not work (because it is a read-only key used by CircleCI to checkout code from git), so you should add another deployment key. | `${VORTEX_DEPLOY_SSH_FINGERPRINT}` | `scripts/vortex/deploy-lagoon.sh` |
| <a id="vortex_deploy_mode"></a>`VORTEX_DEPLOY_MODE` | Deployment mode.<br/><br/>Values can be one of: branch, tag. | `branch` | `scripts/vortex/deploy.sh` |
| <a id="vortex_deploy_mode"></a>`VORTEX_DEPLOY_MODE` | Deployment mode.<br/><br/>Values can be one of: branch, tag. | `branch` | `scripts/vortex/deploy-lagoon.sh`, `scripts/vortex/deploy.sh` |
| <a id="vortex_deploy_pr"></a>`VORTEX_DEPLOY_PR` | Deployment pull request number without "pr-" prefix. | `UNDEFINED` | `scripts/vortex/deploy.sh` |
| <a id="vortex_deploy_skip"></a>`VORTEX_DEPLOY_SKIP` | Skip all deployments. | `UNDEFINED` | `CI config` |
| <a id="vortex_deploy_types"></a>`VORTEX_DEPLOY_TYPES` | Deployment occurs when tests pass in the CI environment. @see https://www.vortextemplate.com/docs/deployment | `artifact` | `.env`, `scripts/vortex/deploy.sh` |
Expand Down
15 changes: 15 additions & 0 deletions .vortex/tests/bats/unit/deploy-lagoon.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@

load ../_helper.bash

@test "Tag deployment mode skips Lagoon deployment" {
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1

export LAGOON_PROJECT="test_project"
export VORTEX_DEPLOY_MODE="tag"

run scripts/vortex/deploy-lagoon.sh
assert_success
assert_output_contains "Started LAGOON deployment."
assert_output_contains "Lagoon does not support tag deployments. Skipping."
assert_output_contains "Finished LAGOON deployment."

popd >/dev/null
}

@test "Deploy fails when LAGOON_PROJECT variable is missing" {
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1

Expand Down
12 changes: 12 additions & 0 deletions scripts/vortex/deploy-lagoon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && if [ -f ./.env.local ]
set -eu
[ "${VORTEX_DEBUG-}" = "1" ] && set -x

# Deployment mode.
#
# Values can be one of: branch, tag.
VORTEX_DEPLOY_MODE="${VORTEX_DEPLOY_MODE:-branch}"

# Deployment action.
#
# Values can be one of: deploy, deploy_override_db, destroy.
Expand Down Expand Up @@ -95,6 +100,13 @@ exit_code=0

info "Started LAGOON deployment."

# Lagoon does not support tag deployments. Exit successfully with a message.
if [ "${VORTEX_DEPLOY_MODE}" = "tag" ]; then
note "Lagoon does not support tag deployments. Skipping."
pass "Finished LAGOON deployment."
exit 0
fi

## Check all required values.
[ -z "${VORTEX_DEPLOY_LAGOON_PROJECT}" ] && fail "Missing required value for VORTEX_DEPLOY_LAGOON_PROJECT or LAGOON_PROJECT." && exit 1
{ [ -z "${VORTEX_DEPLOY_LAGOON_BRANCH}" ] && [ -z "${VORTEX_DEPLOY_LAGOON_PR}" ]; } && fail "Missing required value for VORTEX_DEPLOY_LAGOON_BRANCH or VORTEX_DEPLOY_BRANCH or VORTEX_DEPLOY_LAGOON_PR or VORTEX_DEPLOY_PR." && exit 1
Expand Down