Skip to content

Commit b7dc131

Browse files
committed
[#1219] Added tag deployment mode skip in Lagoon deploy script.
1 parent 9af076d commit b7dc131

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

.vortex/docs/content/development/variables.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ The list below is automatically generated with [Shellvar](https://github.com/ale
216216
| <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` |
217217
| <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` |
218218
| <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` |
219-
| <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` |
219+
| <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` |
220220
| <a id="vortex_deploy_pr"></a>`VORTEX_DEPLOY_PR` | Deployment pull request number without "pr-" prefix. | `UNDEFINED` | `scripts/vortex/deploy.sh` |
221221
| <a id="vortex_deploy_skip"></a>`VORTEX_DEPLOY_SKIP` | Skip all deployments. | `UNDEFINED` | `CI config` |
222222
| <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` |

.vortex/tests/bats/unit/deploy-lagoon.bats

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@
66

77
load ../_helper.bash
88

9+
@test "Tag deployment mode skips Lagoon deployment" {
10+
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
11+
12+
export LAGOON_PROJECT="test_project"
13+
export VORTEX_DEPLOY_MODE="tag"
14+
15+
run scripts/vortex/deploy-lagoon.sh
16+
assert_success
17+
assert_output_contains "Started LAGOON deployment."
18+
assert_output_contains "Lagoon does not support tag deployments. Skipping."
19+
assert_output_contains "Finished LAGOON deployment."
20+
21+
popd >/dev/null
22+
}
23+
924
@test "Deploy fails when LAGOON_PROJECT variable is missing" {
1025
pushd "${LOCAL_REPO_DIR}" >/dev/null || exit 1
1126

scripts/vortex/deploy-lagoon.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && if [ -f ./.env.local ]
1313
set -eu
1414
[ "${VORTEX_DEBUG-}" = "1" ] && set -x
1515

16+
# Deployment mode.
17+
#
18+
# Values can be one of: branch, tag.
19+
VORTEX_DEPLOY_MODE="${VORTEX_DEPLOY_MODE:-branch}"
20+
1621
# Deployment action.
1722
#
1823
# Values can be one of: deploy, deploy_override_db, destroy.
@@ -95,6 +100,13 @@ exit_code=0
95100

96101
info "Started LAGOON deployment."
97102

103+
# Lagoon does not support tag deployments. Exit successfully with a message.
104+
if [ "${VORTEX_DEPLOY_MODE}" = "tag" ]; then
105+
note "Lagoon does not support tag deployments. Skipping."
106+
pass "Finished LAGOON deployment."
107+
exit 0
108+
fi
109+
98110
## Check all required values.
99111
[ -z "${VORTEX_DEPLOY_LAGOON_PROJECT}" ] && fail "Missing required value for VORTEX_DEPLOY_LAGOON_PROJECT or LAGOON_PROJECT." && exit 1
100112
{ [ -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

0 commit comments

Comments
 (0)