Skip to content

Commit 8d993ea

Browse files
Joshua CroftJoshua Croft
authored andcommitted
deploys
1 parent 68a1c7e commit 8d993ea

File tree

5 files changed

+421
-0
lines changed

5 files changed

+421
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy Production
2+
3+
on:
4+
push:
5+
branches:
6+
- release/production
7+
8+
jobs:
9+
build:
10+
name: Build Images
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Gcloud Auth
20+
uses: google-github-actions/auth@v1
21+
with:
22+
credentials_json: "${{ secrets.ORG_PRODUCTION_IMAGES_PUSH }}"
23+
24+
- name: Setup Cloud SDK
25+
uses: google-github-actions/setup-gcloud@v1
26+
27+
- name: Set Image Tag
28+
id: lookup
29+
run: echo "version=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
30+
31+
- run: |
32+
gcloud auth list
33+
gcloud auth configure-docker -q
34+
echo "VERSION: ${{ steps.lookup.outputs.version }}"
35+
36+
- name: Build and Push Images
37+
run: |
38+
./k8s/build-img.py -p production
39+
env:
40+
BACKEND_URL: ${{ secrets.NEXT_PUBLIC_BACKEND_URL }}
41+
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
42+
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
43+
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
44+
NEXT_PUBLIC_ALGOLIA_INDEX: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX }}
45+
NEWSLETTER_BASE_URL: ${{ secrets.NEWSLETTER_BASE_URL }}
46+
SENDER_TOKEN: ${{ secrets.SENDER_TOKEN }}
47+
48+
- name: Trigger Image Update
49+
run: |
50+
curl -H "Accept: application/vnd.github.everest-preview+json" \
51+
-H "Authorization: token ${{ secrets.ORG_DISPATCH_RENDER_TOKEN }}" \
52+
--request POST \
53+
--data '{"event_type": "docs-build", "client_payload": {"image": "${{ env.IMAGE }}", "image_path": "${{ env.IMAGE_PATH }}", "key_path": "${{ env.KEY_PATH }}", "tag": "${{ env.TAG }}", "commit_message_service": "${{ env.SERVICE_NAME }}"}}' \
54+
${{ env.TARGET_REPO }}
55+
env:
56+
IMAGE: gcr.io/fetch-ai-images/docs-website
57+
KEY_PATH: ".website.image.tag"
58+
TAG: ${{ steps.lookup.outputs.version }}
59+
IMAGE_PATH: values
60+
SERVICE_NAME: Documentation
61+
TARGET_REPO: https://api.github.com/repos/fetchai/infra-production-deployment/dispatches

.github/workflows/deploy-staging.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Deploy Staging
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
name: Build Images
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Setup Gcloud Auth
20+
uses: google-github-actions/auth@v1
21+
with:
22+
credentials_json: "${{ secrets.ORG_SANDBOX_DEPLOYMENT_KEY }}"
23+
24+
- name: Setup Cloud SDK
25+
uses: google-github-actions/setup-gcloud@v1
26+
27+
- name: Set Image Tag
28+
id: lookup
29+
run: echo "version=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
30+
31+
- run: |
32+
gcloud auth list
33+
gcloud auth configure-docker -q
34+
echo "VERSION: ${{ steps.lookup.outputs.version }}"
35+
36+
- name: Build and Push Images
37+
run: |
38+
./k8s/build-img.py -p staging
39+
env:
40+
BACKEND_URL: ${{ secrets.STAGING_NEXT_PUBLIC_BACKEND_URL }}
41+
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
42+
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
43+
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
44+
NEXT_PUBLIC_ALGOLIA_INDEX: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX }}
45+
NEWSLETTER_BASE_URL: ${{ secrets.NEWSLETTER_BASE_URL }}
46+
SENDER_TOKEN: ${{ secrets.SENDER_TOKEN }}
47+
48+
deploy:
49+
name: Deployment
50+
runs-on: ubuntu-latest
51+
52+
needs:
53+
- build
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v3
58+
with:
59+
fetch-depth: 0
60+
61+
- name: Setup Gcloud Auth
62+
uses: google-github-actions/auth@v1
63+
with:
64+
credentials_json: "${{ secrets.ORG_SANDBOX_DEPLOYMENT_KEY }}"
65+
66+
- name: Setup Cloud SDK
67+
uses: google-github-actions/setup-gcloud@v1
68+
69+
- name: Set Image Tag
70+
id: lookup
71+
run: echo "version=$(git describe --always --dirty=-wip)" >> $GITHUB_OUTPUT
72+
73+
- name: Turnstyle
74+
uses: softprops/turnstyle@v1
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Deploy to Staging
79+
env:
80+
IMAGE_TAG: ${{ steps.lookup.outputs.version }}
81+
HELM_NAME: staging
82+
NAMESPACE: docs-staging
83+
GKE_PROJECT: fetch-ai-sandbox
84+
GKE_CLUSTER: london-b
85+
GKE_ZONE: europe-west2-b
86+
87+
run: |
88+
gcloud components install gke-gcloud-auth-plugin
89+
gcloud container clusters get-credentials $GKE_CLUSTER \
90+
--zone $GKE_ZONE \
91+
--project $GKE_PROJECT
92+
helm upgrade --install --wait --timeout 300s $HELM_NAME \
93+
./k8s/docs/ \
94+
--set-string website.image.tag=$IMAGE_TAG \
95+
-n $NAMESPACE
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Clean Ephemeral Deployment
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
jobs:
9+
clean-deployment:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup Gcloud Auth
19+
uses: google-github-actions/auth@v1
20+
with:
21+
credentials_json: "${{ secrets.ORG_SANDBOX_DEPLOYMENT_KEY }}"
22+
23+
- name: Setup Cloud SDK
24+
uses: google-github-actions/setup-gcloud@v1
25+
26+
- name: Set Image Tag
27+
id: lookup
28+
run: echo "version=$(git describe --always --dirty=-wip)" >> $GITHUB_OUTPUT
29+
30+
- name: Turnstyle
31+
uses: softprops/turnstyle@v1
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Uninstall Deployment
36+
env:
37+
HELM_NAME: ephemeral-${{ github.event.pull_request.number }}
38+
NAMESPACE: docs-staging
39+
GKE_PROJECT: fetch-ai-sandbox
40+
GKE_CLUSTER: london-b
41+
GKE_ZONE: europe-west2-b
42+
PR_NUMBER: ${{ github.event.pull_request.number }}
43+
HELM_NAME_INGRESS: ephemeral-ingress-${{ github.event.pull_request.number }}
44+
45+
run: |
46+
gcloud components install gke-gcloud-auth-plugin
47+
gcloud container clusters get-credentials $GKE_CLUSTER \
48+
--zone $GKE_ZONE \
49+
--project $GKE_PROJECT
50+
helm uninstall $HELM_NAME -n $NAMESPACE
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Ephemeral (Testing) Deployment
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
10+
jobs:
11+
build:
12+
name: Build Images
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Setup Gcloud Auth
22+
uses: google-github-actions/auth@v1
23+
with:
24+
credentials_json: "${{ secrets.ORG_SANDBOX_DEPLOYMENT_KEY }}"
25+
26+
- name: Setup Cloud SDK
27+
uses: google-github-actions/setup-gcloud@v1
28+
29+
- name: Set Image Tag
30+
id: lookup
31+
run: echo "version=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
32+
33+
- run: |
34+
gcloud auth list
35+
gcloud auth configure-docker -q
36+
echo "VERSION: ${{ steps.lookup.outputs.version }}"
37+
38+
- name: Build and Push Images
39+
run: ./k8s/build-img.py -p staging
40+
env:
41+
BACKEND_URL: ${{ secrets.STAGING_NEXT_PUBLIC_BACKEND_URL }}
42+
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
43+
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
44+
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
45+
NEXT_PUBLIC_ALGOLIA_INDEX: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX }}
46+
NEWSLETTER_BASE_URL: ${{ secrets.NEWSLETTER_BASE_URL }}
47+
SENDER_TOKEN: ${{ secrets.SENDER_TOKEN }}
48+
49+
deploy:
50+
name: Ephermeral Deployment
51+
runs-on: ubuntu-latest
52+
needs: build
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v3
57+
with:
58+
fetch-depth: 0
59+
60+
- name: Setup Gcloud Auth
61+
uses: google-github-actions/auth@v1
62+
with:
63+
credentials_json: "${{ secrets.ORG_SANDBOX_DEPLOYMENT_KEY }}"
64+
65+
- name: Setup Cloud SDK
66+
uses: google-github-actions/setup-gcloud@v1
67+
68+
- name: Set Image Tag
69+
id: lookup
70+
run: echo "version=$(git describe --always --dirty=-wip)" >> $GITHUB_OUTPUT
71+
72+
- name: Turnstyle
73+
uses: softprops/turnstyle@v1
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Deploy to Staging
78+
env:
79+
IMAGE_TAG: ${{ steps.lookup.outputs.version }}
80+
HELM_NAME: ephemeral-${{ github.event.pull_request.number }}
81+
NAMESPACE: docs-staging
82+
GKE_PROJECT: fetch-ai-sandbox
83+
GKE_CLUSTER: london-b
84+
GKE_ZONE: europe-west2-b
85+
PR_NUMBER: ${{ github.event.pull_request.number }}
86+
DNS: docs-ephemeral-${{ github.event.pull_request.number }}.sandbox-london-b.fetch-ai.com
87+
CERT: docs-ephemeral-${{ github.event.pull_request.number }}
88+
CERT_NAME: docs-ephemeral-cert-${{ github.event.pull_request.number }}
89+
EPHEMERAL: true
90+
run: |
91+
gcloud components install gke-gcloud-auth-plugin
92+
gcloud container clusters get-credentials $GKE_CLUSTER \
93+
--zone $GKE_ZONE \
94+
--project $GKE_PROJECT
95+
helm upgrade --install --wait --timeout 300s $HELM_NAME \
96+
./k8s/docs/ \
97+
--set-string website.image.tag=$IMAGE_TAG \
98+
--set-string prVersion=${{ github.event.pull_request.number }} \
99+
-n $NAMESPACE \
100+
--set-string dns.name=$DNS \
101+
--set-string tls.cert=$CERT \
102+
--set-string tls.certName=$CERT_NAME \
103+
--set dns.additionalHosts=null \

0 commit comments

Comments
 (0)