Skip to content

Commit

Permalink
ci: Deploy devopsaci-landing (to production) and devopsaci.cz to test
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejsika committed Feb 3, 2022
1 parent 46f9400 commit 3007b68
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions generate-gitlab-ci-statica.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
{"name": "digitalocean.cz"},
{"name": "devopsnews.cz"},
{"name": "hashicorp.cz"},
{"name": "devopsaci.cz"},
{"name": "devopsaci-landing", "domain": "devopsaci.cz"},
{"name": "sikahosting.com"},
]

SITES_SITES20_DEV = [
{"name": "devopsaci.cz"},
]

_DEFAULT_DEPENDENCIES = [
"packages/data/**/*",
"packages/common/**/*",
Expand Down Expand Up @@ -178,6 +182,7 @@ def gen_deps(deps, name):
for site in SITES_SITES20:
name = site["name"]
deps = _SITES20_DEPENDENCIES
domain = site.get("domain", name)
out.update(
{
"deploy sites20 %s"
Expand Down Expand Up @@ -208,7 +213,7 @@ def gen_deps(deps, name):
% name: {
"stage": "deploy validate",
"script": [
"COMMIT=$(curl -fsSL https://%s/api/version.json | jq -r .git_commit)" % name,
"COMMIT=$(curl -fsSL https://%s/api/version.json | jq -r .git_commit)" % domain,
"[ $COMMIT == $CI_COMMIT_SHA ]",
],
"only": {
Expand All @@ -225,5 +230,50 @@ def gen_deps(deps, name):
}
)

for site in SITES_SITES20_DEV:
name = site["name"]
deps = _SITES20_DEPENDENCIES
statica_domain = (
"test-" + name.replace(".", "-") + "-$CI_COMMIT_REF_SLUG.$STATICA_BASE_DOMAIN"
)
out.update(
{
"deploy dev sites20 %s"
% name: {
"stage": "deploy",
"script": [
"mkdir -p sites20/sites/%s/public/api" % name,
"slu static-api version --set-git-clean --set-git-ref $CI_COMMIT_REF_NAME -e CI_PIPELINE_ID=$CI_PIPELINE_ID -e \"GITLAB_USER_LOGIN=$GITLAB_USER_LOGIN\" -e \"CI_COMMIT_TITLE=$CI_COMMIT_TITLE\" > sites20/sites/%s/public/api/version.json" % name,
"cd sites20",
"rm -rf ./sites/%s/out" % name,
"yarn --cache-folder .yarn-cache",
"statica %s ./sites/%s/out" % (statica_domain, name)
],
"only": {
"changes": gen_deps(deps, name),
},
"needs": [],
}
}
)
out.update(
{
"validate dev %s"
% name: {
"stage": "deploy validate",
"script": [
"COMMIT=$(curl -fsSL https://%s/api/version.json | jq -r .git_commit)" % statica_domain,
"[ $COMMIT == $CI_COMMIT_SHA ]",
],
"only": {
"changes": gen_deps(deps, name),
},
"needs": [
"deploy dev sites20 %s" % name,
],
}
}
)

with open(".gitlab-ci-statica.generated.yml", "w") as f:
f.write(json.dumps(out))

0 comments on commit 3007b68

Please sign in to comment.