Skip to content

Commit

Permalink
Updated Lagoon deployment script to use long-form options.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Aug 27, 2024
1 parent f0bbe9e commit 124522e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions scripts/drevops/deploy-lagoon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ for cmd in lagoon curl; do command -v ${cmd} >/dev/null || {

note "Configuring Lagoon instance."
#shellcheck disable=SC2218
lagoon config add --force -l "${DREVOPS_DEPLOY_LAGOON_INSTANCE}" -g "${DREVOPS_DEPLOY_LAGOON_INSTANCE_GRAPHQL}" -H "${DREVOPS_DEPLOY_LAGOON_INSTANCE_HOSTNAME}" -P "${DREVOPS_DEPLOY_LAGOON_INSTANCE_PORT}"
lagoon config add --force --lagoon "${DREVOPS_DEPLOY_LAGOON_INSTANCE}" --graphql "${DREVOPS_DEPLOY_LAGOON_INSTANCE_GRAPHQL}" --hostname "${DREVOPS_DEPLOY_LAGOON_INSTANCE_HOSTNAME}" --port "${DREVOPS_DEPLOY_LAGOON_INSTANCE_PORT}"

Check warning on line 112 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L112

Added line #L112 was not covered by tests

lagoon() { command lagoon --force --skip-update-check -i "${DREVOPS_DEPLOY_SSH_FILE}" -l "${DREVOPS_DEPLOY_LAGOON_INSTANCE}" -p "${LAGOON_PROJECT}" "$@"; }
lagoon() { command lagoon --force --skip-update-check --ssh-key "${DREVOPS_DEPLOY_SSH_FILE}" --lagoon "${DREVOPS_DEPLOY_LAGOON_INSTANCE}" --project "${LAGOON_PROJECT}" "$@"; }

# ACTION: 'destroy'
# Explicitly specifying "destroy" action as a failsafe.
if [ "${DREVOPS_DEPLOY_ACTION}" = "destroy" ]; then
note "Destroying environment: project ${LAGOON_PROJECT}, branch: ${DREVOPS_DEPLOY_BRANCH}."
lagoon delete environment -e "${DREVOPS_DEPLOY_BRANCH}" || true
lagoon delete environment --environment "${DREVOPS_DEPLOY_BRANCH}" || true

Check warning on line 120 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L120

Added line #L120 was not covered by tests

# ACTION: 'deploy' OR 'deploy_override_db'
else
Expand All @@ -144,32 +144,32 @@ else

# Explicitly set DB overwrite flag to 0 due to a bug in Lagoon.
# @see https://github.com/uselagoon/lagoon/issues/1922
lagoon update variable -e "${deploy_pr_full}" -N DREVOPS_PROVISION_OVERRIDE_DB -V 0 -S global || true
lagoon update variable --environment "${deploy_pr_full}" --name DREVOPS_PROVISION_OVERRIDE_DB --value 0 --scope global || true

Check warning on line 147 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L147

Added line #L147 was not covered by tests

# Override DB during re-deployment.
if [ "${DREVOPS_DEPLOY_ACTION}" = "deploy_override_db" ]; then
note "Add a DB import override flag for the current deployment."
# To update variable value, we need to remove it and add again.
lagoon update variable -e "${deploy_pr_full}" -N DREVOPS_PROVISION_OVERRIDE_DB -V 1 -S global || true
lagoon update variable --environment "${deploy_pr_full}" --name DREVOPS_PROVISION_OVERRIDE_DB --value 1 --scope global || true

Check warning on line 153 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L153

Added line #L153 was not covered by tests
fi

note "Redeploying environment: project ${LAGOON_PROJECT}, PR: ${DREVOPS_DEPLOY_PR}."
lagoon deploy pullrequest -n "${DREVOPS_DEPLOY_PR}" -N "${DREVOPS_DEPLOY_PR_BASE_BRANCH}" -R "origin/${DREVOPS_DEPLOY_PR_BASE_BRANCH}" -H "${DREVOPS_DEPLOY_BRANCH}" -M "${DREVOPS_DEPLOY_PR_HEAD}" -t "${deploy_pr_full}"
lagoon deploy pullrequest --number "${DREVOPS_DEPLOY_PR}" --name "${DREVOPS_DEPLOY_PR_BASE_BRANCH}" --base-branch-ref "origin/${DREVOPS_DEPLOY_PR_BASE_BRANCH}" --hostname "${DREVOPS_DEPLOY_BRANCH}" --head-branch-ref "${DREVOPS_DEPLOY_PR_HEAD}" --title "${deploy_pr_full}"

Check warning on line 157 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L157

Added line #L157 was not covered by tests

if [ "${DREVOPS_DEPLOY_ACTION:-}" = "deploy_override_db" ]; then
note "Waiting for deployment to be queued."
sleep 10

note "Remove a DB import override flag for the current deployment."
# Note that a variable will be read by Lagoon during queuing of the build.
lagoon update variable -e "${deploy_pr_full}" -N DREVOPS_PROVISION_OVERRIDE_DB -V 0 -S global || true
lagoon update variable --environment "${deploy_pr_full}" --name DREVOPS_PROVISION_OVERRIDE_DB --value 0 --scope global || true

Check warning on line 165 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L165

Added line #L165 was not covered by tests
fi

# Deployment of the fresh environment.
else
# If PR deployments are not configured in Lagoon - it will filter it out and will not deploy.
note "Deploying environment: project ${LAGOON_PROJECT}, PR: ${DREVOPS_DEPLOY_PR}."
lagoon deploy pullrequest -n "${DREVOPS_DEPLOY_PR}" -N "${DREVOPS_DEPLOY_PR_BASE_BRANCH}" -R "origin/${DREVOPS_DEPLOY_PR_BASE_BRANCH}" -H "${DREVOPS_DEPLOY_BRANCH}" -M "${DREVOPS_DEPLOY_PR_HEAD}" -t "${deploy_pr_full}"
lagoon deploy pullrequest --name "${DREVOPS_DEPLOY_PR}" --name "${DREVOPS_DEPLOY_PR_BASE_BRANCH}" --base-branch-ref "origin/${DREVOPS_DEPLOY_PR_BASE_BRANCH}" --hostname "${DREVOPS_DEPLOY_BRANCH}" --head-branch-ref "${DREVOPS_DEPLOY_PR_HEAD}" --title "${deploy_pr_full}"

Check warning on line 172 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L172

Added line #L172 was not covered by tests
fi

# Deploy branch.
Expand All @@ -193,32 +193,32 @@ else

# Explicitly set DB overwrite flag to 0 due to a bug in Lagoon.
# @see https://github.com/uselagoon/lagoon/issues/1922
lagoon update variable -e "${DREVOPS_DEPLOY_BRANCH}" -N DREVOPS_PROVISION_OVERRIDE_DB -V 0 -S global || true
lagoon update variable --environment "${DREVOPS_DEPLOY_BRANCH}" --name DREVOPS_PROVISION_OVERRIDE_DB --value 0 --scope global || true

Check warning on line 196 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L196

Added line #L196 was not covered by tests

# Override DB during re-deployment.
if [ "${DREVOPS_DEPLOY_ACTION:-}" = "deploy_override_db" ]; then
note "Add a DB import override flag for the current deployment."
# To update variable value, we need to remove it and add again.
lagoon update variable -e "${DREVOPS_DEPLOY_BRANCH}" -N DREVOPS_PROVISION_OVERRIDE_DB -V 1 -S global || true
lagoon update variable --environment "${DREVOPS_DEPLOY_BRANCH}" --name DREVOPS_PROVISION_OVERRIDE_DB --value 1 --scope global || true

Check warning on line 202 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L202

Added line #L202 was not covered by tests
fi

note "Redeploying environment: project ${LAGOON_PROJECT}, branch: ${DREVOPS_DEPLOY_BRANCH}."
lagoon deploy latest -e "${DREVOPS_DEPLOY_BRANCH}" || true
lagoon deploy latest --environment "${DREVOPS_DEPLOY_BRANCH}" || true

Check warning on line 206 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L206

Added line #L206 was not covered by tests

if [ "${DREVOPS_DEPLOY_ACTION:-}" = "deploy_override_db" ]; then
note "Waiting for deployment to be queued."
sleep 10

note "Remove a DB import override flag for the current deployment."
# Note that a variable will be read by Lagoon during queuing of the build.
lagoon update variable -e "${DREVOPS_DEPLOY_BRANCH}" -N DREVOPS_PROVISION_OVERRIDE_DB -V 0 -S global || true
lagoon update variable --environment "${DREVOPS_DEPLOY_BRANCH}" --name DREVOPS_PROVISION_OVERRIDE_DB --value 0 --scope global || true

Check warning on line 214 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L214

Added line #L214 was not covered by tests
fi

# Deployment of the fresh environment.
else
# If current branch deployments does not match a regex in Lagoon - it will filter it out and will not deploy.
note "Deploying environment: project ${LAGOON_PROJECT}, branch: ${DREVOPS_DEPLOY_BRANCH}."
lagoon deploy branch -b "${DREVOPS_DEPLOY_BRANCH}"
lagoon deploy branch --branch "${DREVOPS_DEPLOY_BRANCH}"

Check warning on line 221 in scripts/drevops/deploy-lagoon.sh

View check run for this annotation

Codecov / codecov/patch

scripts/drevops/deploy-lagoon.sh#L221

Added line #L221 was not covered by tests
fi
fi
fi
Expand Down

1 comment on commit 124522e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.