Skip to content

Commit 210cd9d

Browse files
authored
Merge branch 'develop' into develop
2 parents 902ca23 + e9c8011 commit 210cd9d

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed

.github/workflows/deploy-staging.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy to staging
2+
on:
3+
workflow_run:
4+
workflows: ["Test"]
5+
branches:
6+
- develop
7+
types:
8+
- completed
9+
env:
10+
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
11+
GKE_CLUSTER: p5js-web-editor-cluster
12+
GKE_ZONE: us-east1-c
13+
DEPLOYMENT_NAME: web-editor-node
14+
IMAGE: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor-staging
15+
jobs:
16+
push_to_registry:
17+
environment: staging
18+
name: Push Docker image to Docker Hub
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v2
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v1
25+
- name: Login to Docker Hub
26+
uses: docker/login-action@v1
27+
with:
28+
username: ${{ secrets.DOCKER_USERNAME }}
29+
password: ${{ secrets.DOCKER_PASSWORD }}
30+
- name: Build and push to Docker Hub
31+
uses: docker/build-push-action@v2
32+
with:
33+
context: .
34+
file: ./Dockerfile
35+
pull: true
36+
push: true
37+
tags: |
38+
${{ env.IMAGE }}:${{ github.sha }}
39+
${{ env.IMAGE }}:latest
40+
target: production
41+
# Setup gcloud CLI
42+
- uses: google-github-actions/setup-gcloud@v0.2.0
43+
with:
44+
service_account_key: ${{ secrets.GKE_SA_KEY }}
45+
project_id: ${{ secrets.GKE_PROJECT }}
46+
47+
# Configure docker to use the gcloud command-line tool as a credential helper
48+
- run: |-
49+
gcloud --quiet auth configure-docker
50+
51+
# Get the GKE credentials so we can deploy to the cluster
52+
- uses: google-github-actions/get-gke-credentials@v0.2.1
53+
with:
54+
cluster_name: ${{ env.GKE_CLUSTER }}
55+
location: ${{ env.GKE_ZONE }}
56+
credentials: ${{ secrets.GKE_SA_KEY }}
57+
58+
# Deploy the Docker image to the GKE cluster
59+
- name: Deploy
60+
run: |-
61+
kubectl set image deployment/$DEPLOYMENT_NAME web-editor-app=index.docker.io/$IMAGE:$GITHUB_SHA --namespace=staging
62+
kubectl get services -o wide

.github/workflows/deploy.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy to production
2+
on:
3+
workflow_run:
4+
workflows: ["Test"]
5+
branches:
6+
- release
7+
types:
8+
- completed
9+
env:
10+
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
11+
GKE_CLUSTER: p5js-web-editor-cluster
12+
GKE_ZONE: us-east1-c
13+
DEPLOYMENT_NAME: web-editor-node
14+
IMAGE: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor
15+
jobs:
16+
push_to_registry:
17+
environment: production
18+
name: Push Docker image to Docker Hub
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v2
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v1
25+
- name: Login to Docker Hub
26+
uses: docker/login-action@v1
27+
with:
28+
username: ${{ secrets.DOCKER_USERNAME }}
29+
password: ${{ secrets.DOCKER_PASSWORD }}
30+
- name: Build and push to Docker Hub
31+
uses: docker/build-push-action@v2
32+
with:
33+
context: .
34+
file: ./Dockerfile
35+
pull: true
36+
push: true
37+
tags: |
38+
${{ env.IMAGE }}:${{ github.sha }}
39+
${{ env.IMAGE }}:latest
40+
target: production
41+
# Setup gcloud CLI
42+
- uses: google-github-actions/setup-gcloud@v0.2.0
43+
with:
44+
service_account_key: ${{ secrets.GKE_SA_KEY }}
45+
project_id: ${{ secrets.GKE_PROJECT }}
46+
47+
# Configure docker to use the gcloud command-line tool as a credential helper
48+
- run: |-
49+
gcloud --quiet auth configure-docker
50+
51+
# Get the GKE credentials so we can deploy to the cluster
52+
- uses: google-github-actions/get-gke-credentials@v0.2.1
53+
with:
54+
cluster_name: ${{ env.GKE_CLUSTER }}
55+
location: ${{ env.GKE_ZONE }}
56+
credentials: ${{ secrets.GKE_SA_KEY }}
57+
58+
# Deploy the Docker image to the GKE cluster
59+
- name: Deploy
60+
run: |-
61+
kubectl set image deployment/$DEPLOYMENT_NAME web-editor-app=index.docker.io/$IMAGE:$GITHUB_SHA
62+
kubectl get services -o wide
63+

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test and lint code base
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Use Node.js
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: '12.x'
15+
- run: npm install
16+
- run: npm run test
17+
- run: npm run lint
18+
19+

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ services:
4141
- ML5_EXAMPLES_USERNAME
4242
- ML5_EXAMPLES_PASS
4343
- ML5_EXAMPLES_EMAIL
44+
- UI_ACCESS_TOKEN_ENABLED
45+
- UPLOAD_LIMIT
46+
- TRANSLATIONS_ENABLED
4447
# you can either set this in your .env or as an environment variables
4548
# or here YOU CHOOSE
4649
# - MONGO_URL=mongodb://mongo:27017/p5js-web-editor

0 commit comments

Comments
 (0)