Skip to content

Commit

Permalink
Ensure first deploy is run for all relevant branches when running sit…
Browse files Browse the repository at this point in the history
…es:sync task
  • Loading branch information
hypesystem committed Mar 30, 2024
1 parent e325297 commit 961f7f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
11 changes: 0 additions & 11 deletions docs/runbooks/add-library-site-to-platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,6 @@ $ task sites:sync
# You may be prompted to confirm Terraform plan execution and approve other critical steps.

Check failure on line 118 in docs/runbooks/add-library-site-to-platform.md

View workflow job for this annotation

GitHub Actions / Lint Markdown

Line length [Expected: 80; Actual: 91]
# Read and consider these messages carefully and ensure you are not needlessly changing
# other sites.
#TODO: move first deploys to Taskfile
# 3.a Trigger a deployment manually, this will fail as the repository is empty
# but will serve to prepare Lagoon for future deployments.
# lagoon deploy branch -p <project-name> -b <branch>
$ lagoon deploy branch -p core-test1 -b main
# 3.b If you are setting up a site with `plan: webmaster`, you also need to
# deploy the moduletest branch
$ lagoon deploy branch -p core-test1 -b moduletest
```

If you want to deploy a release to the site, continue to
Expand Down
5 changes: 5 additions & 0 deletions docs/runbooks/deploy-a-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ environment for custom Drupal modules will also be synced appropriately.
## Procedure

```sh
# 0. The easiest way to sync all sites is to run this single command:
task sites:sync

# Alternatively you can go through more granular sync'ing of individual sites...

# 1. Make any changes to the sites entry sites.yml you need.
# 2. (optional) diff the deployment
DIFF=1 SITE=<sitename> task site:sync
Expand Down
24 changes: 20 additions & 4 deletions infrastructure/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -773,13 +773,10 @@ tasks:
SITE="$site" task site:lagoon:project:capture-deploy-key
done
- task: env_repos:provision
- |
echo "TODO: figure out which sites are newly created and require a first deploy\
and run lagoon deploy for them - and for plan:webmaster run deploy of\
moduletest, too"
- |
set -e
cat sites.yaml | yq '.sites | keys | .[]' | while read -r site; do
SITE="$site" task site:lagoon:ensure-first-deployment
SITE="$site" task site:sync
done
Expand Down Expand Up @@ -822,6 +819,25 @@ tasks:
- sh: "[ ! -z {{.SITE}} ]"
msg: "Env variable SITE is not set or empty."

site:lagoon:ensure-first-deployment:
desc: Ensures that a site has at least one deployment on required branches, so they are tracked by Lagoon
deps: [lagoon:cli:config]
dir: "{{.dir_env}}"
env:
SITE: "{{.SITE}}"
cmds:
- |
if [ "$(lagoon list deployments --project "{{.SITE}}" --environment main --output-json | jq '.data | length')" = "0" ]; then
lagoon deploy branch --project "{{.SITE}}" --branch "main";
fi
- |
if [ "$(yq '.sites[env(SITE)].plan' sites.yaml)" = "webmaster" -a "$(lagoon list deployments --project "{{.SITE}}" --environment moduletest --output-json | jq '.data | length')" = "0" ]; then
lagoon deploy branch --project "{{.SITE}}" --branch "moduletest";
fi
preconditions:
- sh: "[ ! -z {{.SITE}} ]"
msg: "Env variable SITE is not set or empty."

ui-password:
desc: Get the password to access a given user interface
cmds:
Expand Down

0 comments on commit 961f7f1

Please sign in to comment.