Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ AUTH0_CALLBACK_URL=http://localhost:3000/callback
SENDGRID_API_KEY=123456
BASE_URL=http://localhost:3000
HASURA_JWT_SECRET=
GRAPHQL_SERVER_URI=http://localhost:5000
GRAPHQL_SERVER_URI=http://localhost:5000
SPACES_KEY_ID=
SPACES_SECRET_ACCESS_KEY=
17 changes: 17 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,23 @@ deploy_review_hasura:
- kubectl rollout status -f /tmp/deployment.yaml
- kubectl get deploy,svc,ing,pod -l app="$(echo ${CI_PROJECT_NAME} | tr "." "-")",ref="${CI_ENVIRONMENT_SLUG}"

upload_to_cdn:
image:
name: python:latest
entrypoint: ['/bin/sh', '-c']
stage: 'Deploy'
environment:
name: production
url: https://gameofblocks.io
only:
- master
before_script:
- pip install boto3
script:
- cd .gitlab/ci
- echo $SPACES_KEY_ID
- python spaces-uploader.py

############### Stop APP ###############################

stop_review:
Expand Down
40 changes: 40 additions & 0 deletions .gitlab/ci/spaces-uploader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# https://medium.com/@brianobilo/uploading-files-to-digital-ocean-spaces-using-api-keys-and-boto3-1f24242f6cd7
import os
from os import walk
import boto3
from boto3 import session
from botocore.client import Config
from boto3.s3.transfer import S3Transfer

public_folder_path = '../../packages/app/public'

files = []
# r=root, d=directories, f = files
for r, d, f in os.walk(public_folder_path):
print(d)
for file in f:
files.append(os.path.join(r, file))

#Use the API Keys you generated at Digital Ocean
ACCESS_ID = os.environ['SPACES_KEY_ID']
SECRET_KEY = os.environ['SPACES_SECRET_ACCESS_KEY']

# Initiate session
session = session.Session()
client = session.client('s3',
region_name='sfo2',
endpoint_url='https://sfo2.digitaloceanspaces.com',
aws_access_key_id=ACCESS_ID,
aws_secret_access_key=SECRET_KEY)

transfer = S3Transfer(client)
name_of_space = "assets.gameofblocks"

for f in files:
file_to_import = f[(len(public_folder_path) + 1):len(f)]
print(file_to_import)
transfer.upload_file(f, name_of_space, file_to_import)
# This makes the file you are have specifically uploaded public by default.
response = client.put_object_acl(ACL='public-read', Bucket=name_of_space, Key=file_to_import)

print(len(files) + " files uploaded")
Binary file added packages/app/public/images/throne.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.