Skip to content

Commit 97c724d

Browse files
ejfitzgeraldJoshua Croftdevjsc
authored
chore(misc): fix up deployments (#801)
Co-authored-by: Joshua Croft <[email protected]> Co-authored-by: Joshua Croft <[email protected]>
1 parent 4ea32f1 commit 97c724d

File tree

6 files changed

+20
-225
lines changed

6 files changed

+20
-225
lines changed

.github/workflows/deploy-production.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ jobs:
3535
3636
- name: Build and Push Images
3737
run: |
38-
./k8s/build-img.py -p production
38+
./scripts/build-img.py
3939
env:
40+
IMAGE_REPOSITORY: ${{ secrets.PRODUCTION_IMAGE_REPOSITORY }}
4041
BACKEND_URL: ${{ secrets.NEXT_PUBLIC_BACKEND_URL }}
4142
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
4243
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}

.github/workflows/deploy-staging.yml

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ jobs:
3535
3636
- name: Build and Push Images
3737
run: |
38-
./k8s/build-img.py -p staging
38+
./scripts/build-img.py
3939
env:
40+
IMAGE_REPOSITORY: ${{ secrets.STAGING_IMAGE_REPOSITORY }}
4041
BACKEND_URL: ${{ secrets.STAGING_NEXT_PUBLIC_BACKEND_URL }}
4142
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
4243
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
@@ -45,51 +46,10 @@ jobs:
4546
NEWSLETTER_BASE_URL: ${{ secrets.NEWSLETTER_BASE_URL }}
4647
SENDER_TOKEN: ${{ secrets.SENDER_TOKEN }}
4748

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-
49+
- name: Repository Dispatch
8750
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
51+
curl -f -H "Accept: application/vnd.github.everest-preview+json" \
52+
-H "Authorization: token ${{ secrets.ORG_DISPATCH_RENDER_TOKEN }}" \
53+
--request POST \
54+
--data '{"event_type": "docs-staging-build", "client_payload": {"image": "'"${{ secrets.STAGING_IMAGE_REPOSITORY }}"'" , "image_path": "values", "key_path": ".website.image.tag", "commit_message_service": "Docs Staging", "tag": "'"${{ steps.lookup.outputs.version }}"'"}}' \
55+
https://api.github.com/repos/fetchai/infra-sandbox-london-b-deployment/dispatches

.github/workflows/ephemeral-delete.yaml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/ephemeral-deploy.yaml

Lines changed: 0 additions & 103 deletions
This file was deleted.

.github/workflows/pr-title-linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
pull_request_target:
55
types:
66
- opened
7-
- editedgit
7+
- edited
88
- synchronize
99

1010
jobs:

build-img.py renamed to scripts/build-img.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,10 @@
55
import argparse
66

77

8-
PROFILES = {
9-
'staging': {
10-
'repository': 'gcr.io/fetch-ai-sandbox/docs-website',
11-
},
12-
'production': {
13-
'repository': 'gcr.io/fetch-ai-images/docs-website',
14-
},
15-
}
16-
178
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
189

10+
REPOSITORY = os.environ.get('IMAGE_REPOSITORY')
11+
1912
BUILD_ENV_VARS = (
2013
'BACKEND_URL',
2114
'NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID',
@@ -26,18 +19,9 @@
2619
'SENDER_TOKEN'
2720
)
2821

29-
def _profile(text: str) -> str:
30-
if text not in PROFILES:
31-
available_profiles = ', '.join(PROFILES.keys())
32-
print(f'Invalid profile {text}. Please select one of [{available_profiles}]')
33-
sys.exit(1)
34-
35-
return text
36-
3722

3823
def parse_commandline() -> argparse.Namespace:
3924
parser = argparse.ArgumentParser()
40-
parser.add_argument('-p', '--profile', type=_profile, default='staging', help='The profile to use')
4125
parser.add_argument('-n', '--no-push', dest='push', action='store_false', help='Disable pusing of the image')
4226
parser.add_argument('-f', '--force-build', action='store_true', help=argparse.SUPPRESS)
4327
return parser.parse_args()
@@ -55,6 +39,11 @@ def get_version() -> str:
5539
def main():
5640
args = parse_commandline()
5741

42+
# validate the repository environment variable
43+
if REPOSITORY is None:
44+
print('Missing IMAGE_REPOSITORY environment variable')
45+
sys.exit(1)
46+
5847
# argument validation / augmentation
5948
push = args.push
6049
if detect_local_modifications():
@@ -67,13 +56,11 @@ def main():
6756

6857
# lookup the required information
6958
version = get_version()
70-
repository = PROFILES[args.profile]['repository']
7159

72-
image_url = f'{repository}:{version}'
60+
image_url = f'{REPOSITORY}:{version}'
7361

7462
print()
7563
print(f'Project root: {PROJECT_ROOT}')
76-
print(f'Profile.....: {args.profile}')
7764
print(f'Image Ref...: {image_url}')
7865
print(f'Push........: {push}')
7966
print()
@@ -109,4 +96,4 @@ def main():
10996

11097

11198
if __name__ == '__main__':
112-
main()
99+
main()

0 commit comments

Comments
 (0)