Skip to content

Commit 4b3dc6e

Browse files
committed
fix deployment
1 parent 9a565cd commit 4b3dc6e

11 files changed

Lines changed: 50 additions & 38 deletions

.github/workflows/ci.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
needs: [preflight-checks]
2020
runs-on: ubuntu-latest
2121
environment:
22-
name: ${{ github.head_ref }}
22+
name: ${{ github.ref_name }}
2323
url: ${{ steps.deploymentUrl.outputs.url }}
2424
steps:
2525
- uses: actions/checkout@v3
@@ -49,13 +49,13 @@ jobs:
4949

5050
- name: "Installing lttle cli"
5151
run: |
52-
curl -fsSL https://raw.githubusercontent.com/lttle-cloud/ignition/refs/heads/master/get/lttle.sh | bash
52+
curl -fsSL https://install.lttle.sh | bash
5353
5454
- name: "Authenticating with eu.lttle.cloud"
5555
env:
5656
LTTLE_JWT_TOKEN: ${{ secrets.LTTLE_JWT_TOKEN }}
5757
run: |
58-
lttle login --api "http://eu.lttle.cloud:5100" "$LTTLE_JWT_TOKEN"\
58+
lttle login --api "http://eu.lttle.cloud:5100" "$LTTLE_JWT_TOKEN"
5959
6060
- uses: actions/setup-node@v3
6161
with:
@@ -67,7 +67,7 @@ jobs:
6767
- name: "Setting deployment url"
6868
id: deploymentUrl
6969
run: |
70-
url="https://"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
70+
url="https://"$(lttle deploy --eval "git.ref == 'main'? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
7171
echo "url=$url" >> $GITHUB_OUTPUT
7272
7373
# TODO: Split this into several bash functions so that we can use the dedicated docker build actions

.github/workflows/remove-preview-deployment.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ jobs:
1010
if: github.event.pull_request.merged == true
1111
runs-on: ubuntu-latest
1212
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: "Installing lttle cli"
16+
run: |
17+
curl -fsSL https://install.lttle.sh | bash
18+
19+
- name: "Authenticating with eu.lttle.cloud"
20+
env:
21+
LTTLE_JWT_TOKEN: ${{ secrets.LTTLE_JWT_TOKEN }}
22+
run: |
23+
lttle login --api "http://eu.lttle.cloud:5100" "$LTTLE_JWT_TOKEN"
24+
1325
- name: "Remove Preview Deployment"
1426
run: |
1527
./remove.sh

deploy-docs.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ if [ -z "${GITHUB_HEAD_REF+x}" ]; then
1313
export GITHUB_HEAD_REF
1414
fi
1515

16-
namespace="docs-"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'")
17-
tag=$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch'")
16+
namespace="docs-"$(lttle deploy --eval "git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'")
17+
tag=$(lttle deploy --eval "git.ref == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch'")
1818

19-
docsURL="https://"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
20-
typesenseFQDN=$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
19+
docsURL="https://"$(lttle deploy --eval "git.ref == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
20+
typesenseFQDN=$(lttle deploy --eval "git.ref == 'main' ? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
2121

2222
deployDocs "$namespace" "$tag" "$docsURL" "$typesenseFQDN"

deploy-typesense.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ if [ -z "${GITHUB_HEAD_REF+x}" ]; then
1313
export GITHUB_HEAD_REF
1414
fi
1515

16-
namespace="docs-"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'");
17-
tag=$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch'")
16+
namespace="docs-"$(lttle deploy --eval "git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'");
17+
tag=$(lttle deploy --eval "git.ref == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch'")
1818

19-
docsURL="https://"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
20-
typesenseFQDN=$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
19+
docsURL="https://"$(lttle deploy --eval "git.ref == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
20+
typesenseFQDN=$(lttle deploy --eval "git.ref == 'main' ? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
2121

2222
deployTypeSense "$namespace" "$tag" "$docsURL" "$typesenseFQDN"

deploy.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ if [ -z "${GITHUB_HEAD_REF+x}" ]; then
1313
export GITHUB_HEAD_REF
1414
fi
1515

16+
lttle deploy --eval "" --debug-context
1617

17-
namespace="docs-"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'");
18-
tag=$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch'")
18+
namespace="docs-"$(lttle deploy --eval "git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'");
19+
tag=$(lttle deploy --eval "git.ref == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch'")
1920

20-
docsURL="https://"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'");
21-
typesenseFQDN=$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
21+
docsURL="https://"$(lttle deploy --eval "git.ref == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'");
22+
typesenseFQDN=$(lttle deploy --eval "git.ref == 'main' ? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host'")
2223

2324
deployDocs "$namespace" "$tag" "$docsURL" "$typesenseFQDN"
2425
deployTypeSense "$namespace" "$tag" "$docsURL"

lttle/docs.lttle.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
machine:
3-
namespace: "docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
3+
namespace: "docs-${{ git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
44
name: nginx-docs
5-
image: "aifrim/lttle-docs:${{ env.GITHUB_HEAD_REF == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch' }}"
5+
image: "aifrim/lttle-docs:${{ git.ref == 'main'? 'latest' : env.GITHUB_HEAD_REF + '-branch' }}"
66
# IMPORTANT: nginx-docs memory & cpu configuration
77
# For the time being, 1 vCPU and 512 MiB should suffice
88
# To be re-visited later - post-MVP
99
resources:
1010
cpu: 1
1111
# Production 512MiB, Preview Environments for branches: 64Mib
12-
memory: "${{ env.GITHUB_HEAD_REF == 'main' ? 512 : 64 }}"
12+
memory: "${{ git.ref == 'main'? 512 : 64 }}"
1313
mode:
1414
flash:
1515
# NOTE: We only need a timeout when NGINX is initially being setup
@@ -19,7 +19,7 @@ machine:
1919
listen-on-port: 80
2020
---
2121
service:
22-
namespace: "docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
22+
namespace: "docs-${{ git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
2323
name: docs-ingress
2424
target:
2525
name: nginx-docs
@@ -29,6 +29,6 @@ service:
2929
external:
3030
# Production is docs.lttle.aifrim.com (for now) where we have dedicated certificate
3131
# Preview Environments are reusing the same wildcard certificate from *.eu.lttle.host
32-
host: "${{ env.GITHUB_HEAD_REF == 'main' ? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host' }}"
32+
host: "${{ git.ref == 'main'? 'docs.lttle.aifrim.com' : 'docs-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host' }}"
3333
protocol: https
34-
certificate: "${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : null }}"
34+
certificate: "${{ git.ref == 'main'? 'main' : null }}"

lttle/typesense.lttle.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# FIXME: Only allow certain domains to call this machine by enabling CORS
33
# TODO: Look for other important security measures for TypeSense
44
machine:
5-
namespace: "docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
5+
namespace: "docs-${{ git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
66
name: typesense-search
77
image: typesense/typesense:29.0
88
# IMPORTANT: typesense memory & cpu configuration
@@ -30,9 +30,9 @@ machine:
3030
TYPESENSE_DATA_DIR: /data
3131
---
3232
machine:
33-
namespace: "docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
33+
namespace: "docs-${{ git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
3434
name: typesense-scraper
35-
image: "aifrim/typesense-scraper:${{ env.GITHUB_HEAD_REF == 'main' ? 'latest' : env.GITHUB_HEAD_REF + '-branch' }}"
35+
image: "aifrim/typesense-scraper:${{ git.ref == 'main'? 'latest' : env.GITHUB_HEAD_REF + '-branch' }}"
3636
# TODO: Check memory usage of the TypeSense Scraper and adjust memory
3737
resources:
3838
cpu: 1
@@ -56,7 +56,7 @@ machine:
5656
# TODO: Must get this from an environment variable
5757
TYPESENSE_API_KEY: ${{ env.TYPESENSE_API_KEY }}
5858
# This is service-name.namespace.svc.lttle.local
59-
TYPESENSE_HOST: "typesense-search-internal.docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}.svc.lttle.local"
59+
TYPESENSE_HOST: "typesense-search-internal.docs-${{ git.ref == 'main'? 'main' : env.GITHUB_HEAD_REF + '-branch' }}.svc.lttle.local"
6060
# NOTE: Does this really need to always be a string, can it not be
6161
# A number or a boolean, and then we can transform it to a string?
6262
TYPESENSE_PORT: "8108"
@@ -70,22 +70,22 @@ machine:
7070
---
7171
# This makes typesense reachable from the docs search
7272
service:
73-
namespace: "docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
73+
namespace: "docs-${{ git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
7474
name: typesense-search-ingress
7575
target:
7676
name: typesense-search
7777
port: 8108
7878
protocol: http
7979
bind:
8080
external:
81-
host: "${{ env.GITHUB_HEAD_REF == 'main' ? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host' }}"
81+
host: "${{ git.ref == 'main'? 'docs-search.lttle.aifrim.com' : 'docs-search-' + env.GITHUB_HEAD_REF + '-lttle-aifrim.eu.lttle.host' }}"
8282
protocol: https
83-
certificate: "${{ env.GITHUB_HEAD_REF == 'main' ? 'cert-docs' : null }}"
83+
certificate: "${{ git.ref == 'main'? 'cert-docs' : null }}"
8484
---
8585
# This makes typesense reachable internally
8686
# We point the typesense-scraper to send scraped data to this internal service
8787
service:
88-
namespace: "docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
88+
namespace: "docs-${{ git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
8989
name: typesense-search-internal
9090
target:
9191
name: typesense-search
@@ -96,7 +96,7 @@ service:
9696
internal: {}
9797
---
9898
volume:
99-
namespace: "docs-${{ env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
99+
namespace: "docs-${{ git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch' }}"
100100
mode: writeable
101101
name: typesense-search
102102
# NOTE: This may be too much for now. Since the size of the docs I would say

remove.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ if [ -z "${GITHUB_HEAD_REF+x}" ]; then
1313
export GITHUB_HEAD_REF
1414
fi
1515

16-
namespace="docs-"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'")
16+
namespace="docs-"$(lttle deploy --eval "git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'")
1717

18-
# if the namespace is docs-main, we stop
19-
if [ "$namespace" == "docs-main" ]; then
18+
# if [ "$namespace" == "docs-main" ]; then
2019
echo "We do not remove the main documentation"
21-
exit 0
20+
exit 1
2221
fi
2322

2423
echo "Removing machines for namespace $namespace"

restart.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ if [ -z "${GITHUB_HEAD_REF+x}" ]; then
1313
export GITHUB_HEAD_REF
1414
fi
1515

16-
namespace="docs-"$(lttle deploy --eval "env.GITHUB_HEAD_REF == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'");
16+
namespace="docs-"$(lttle deploy --eval "git.ref == 'main' ? 'main' : env.GITHUB_HEAD_REF + '-branch'");
1717

1818
what="$1"
1919

to-delete

Whitespace-only changes.

0 commit comments

Comments
 (0)