Skip to content

Commit

Permalink
Github Actions implementation (#51)
Browse files Browse the repository at this point in the history
This PR introduces GitHub Actions pipelines into the Kread Frontend
repository's workflow, enabling automated deployment to both the
Emerynet and Mainnet environments.

-  PR -> develop (requires approver) -> Deploys to Emerynet on PR closed
- develop -> PR -> main (requires approver from CODEOWNERS) -> Deploys
to Mainnet on PR closed
 
 CODEOWNERS:
- @carlos-kryha 
- @WietzeSlagman

---------

Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Xabier Almazor <[email protected]>
Co-authored-by: Wietze <[email protected]>
Co-authored-by: CARLOS TRIGO <[email protected]>
Co-authored-by: Xabier Almazor Telek <[email protected]>
  • Loading branch information
6 people authored Oct 12, 2023
1 parent cacaf78 commit 00aa0e2
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 143 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/kread-emerynet-cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI/CD Emerynet

on:
pull_request:
branches:
- develop
types:
- closed

jobs:
build_and_deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
sudo install skaffold /usr/local/bin/
shell: bash

- name: Authenticate with Google Cloud
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.GCP_AUTH_KEY }}
project_id: ${{ secrets.PROJECT_ID }}
export_default_credentials: true

- name: Activate Service Account
run: |
gcloud auth activate-service-account ${{ secrets.GCP_SA }} --key-file=$GOOGLE_APPLICATION_CREDENTIALS
gcloud components install gke-gcloud-auth-plugin
- name: Login to GCR
uses: docker/login-action@v3
with:
registry: eu.gcr.io
username: _json_key
password: ${{ secrets.GCP_AUTH_KEY }}

- name: Login to Kubernetes
uses: azure/k8s-set-context@v1
with:
kubeconfig: ${{ secrets.KUBECONFIG }}
cluster-context: ${{ secrets.CLUSTER_CONTEXT }}
namespace: ${{ secrets.K8S_NAMESPACE_EMERYNET }}

- name: Build and push Docker images
run: |
cd frontend
export $(grep -v '^#' .env.emerynet | xargs)
envsubst < ../deployment/emerynet/workloads/config/ui-config.template.yaml > ../deployment/emerynet/workloads/config/ui-config.yaml
envsubst < skaffold.emerynet.template.yaml > skaffold.emerynet.yaml
skaffold run --filename skaffold.emerynet.yaml
shell: bash

58 changes: 58 additions & 0 deletions .github/workflows/kread-mainnet-cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI/CD Mainnet

on:
pull_request:
branches:
- main
types:
- closed

jobs:
build_and_deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Install Skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
sudo install skaffold /usr/local/bin/
shell: bash

- name: Authenticate with Google Cloud
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.GCP_AUTH_KEY }}
project_id: ${{ secrets.PROJECT_ID }}
export_default_credentials: true

- name: Activate Service Account
run: |
gcloud auth activate-service-account ${{ secrets.GCP_SA }} --key-file=$GOOGLE_APPLICATION_CREDENTIALS
gcloud components install gke-gcloud-auth-plugin
- name: Login to GCR
uses: docker/login-action@v3
with:
registry: eu.gcr.io
username: _json_key
password: ${{ secrets.GCP_AUTH_KEY }}

- name: Login to Kubernetes
uses: azure/k8s-set-context@v1
with:
kubeconfig: ${{ secrets.KUBECONFIG }}
cluster-context: ${{ secrets.CLUSTER_CONTEXT }}
namespace: ${{ secrets.K8S_NAMESPACE_MAINNET }}

- name: Build and push Docker images
run: |
cd frontend
export $(grep -v '^#' .env.mainnet | xargs)
envsubst < ../deployment/mainnet/workloads/config/ui-config.template.yaml > ../deployment/mainnet/workloads/config/ui-config.yaml
envsubst < skaffold.mainnet.template.yaml > skaffold.mainnet.yaml
skaffold run --filename skaffold.mainnet.yaml
shell: bash

2 changes: 2 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* @WietzeSlagman
* @carlos-kryha
38 changes: 0 additions & 38 deletions azure-pipelines-prod.yml

This file was deleted.

58 changes: 0 additions & 58 deletions azure-pipelines.old.yml

This file was deleted.

38 changes: 0 additions & 38 deletions azure-pipelines.yml

This file was deleted.

13 changes: 13 additions & 0 deletions deployment/emerynet/workloads/config/ui-config.template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ui
spec:
selector:
matchLabels:
app: ui
template:
spec:
containers:
- name: ui
image: "eu.gcr.io/web3-335312/kread/frontend-staging/frontend:latest"
23 changes: 23 additions & 0 deletions deployment/emerynet/workloads/ingresses/ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ui-devnet
annotations:
kubernetes.io/ingress.class: "nginx"
cert-manager.io/cluster-issuer: "letsencrypt-staging"
nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/proxy-body-size: 200m
spec:
ports:
- name: 80-tcp
port: 80
protocol: TCP
targetPort: 80
- name: 443-tcp
port: 443
protocol: TCP
targetPort: 443
selector:
app: ui
sessionAffinity: None
type: ClusterIP
7 changes: 7 additions & 0 deletions deployment/emerynet/workloads/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bases:
- ../../base
resources:
- namespace/namespace.yaml
patchesStrategicMerge:
- config/ui-config.yaml
namespace: agoric-makefile-automation
7 changes: 7 additions & 0 deletions deployment/emerynet/workloads/namespace/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: agoric-makefile-automation


Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ spec:
spec:
containers:
- name: ui
image: "$DOCKER_REPO:latest"
image: "eu.gcr.io/web3-335312/kread/frontend-production/frontend:latest"
29 changes: 23 additions & 6 deletions frontend/Dockerfile.ui
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
FROM node:16-alpine as build
FROM node:18-alpine as build

RUN apk --no-cache add --update git python3 make g++

WORKDIR /usr/main/

RUN yarn set version 2 --only-if-needed

ENV GENERATE_SOURCEMAP false
ENV GENERATE_SOURCEMAP true

ARG VITE_DAPP_CONSTANTS_JSON
ENV VITE_DAPP_CONSTANTS_JSON $VITE_DAPP_CONSTANTS_JSON
ARG VITE_RPC
ENV VITE_RPC $VITE_RPC

ARG VITE_BRIDE_HREF
ENV VITE_BRIDE_HREF $VITE_BRIDE_HREF

ARG VITE_BASE_URL
ENV VITE_BASE_URL $VITE_BASE_URL

ARG PINATA_GATEWAY
ENV PINATA_GATEWAY $PINATA_GATEWAY

ARG VITE_NETWORK_CONFIG
ENV VITE_NETWORK_CONFIG $VITE_NETWORK_CONFIG

COPY .yarnrc.yml ./.yarnrc.yml
COPY yarn.lock ./yarn.lock
Expand All @@ -18,9 +30,14 @@ COPY .yarn/ ./.yarn/
COPY .eslintrc.json ./.eslintrc.json
COPY .eslintignore ./.eslintignore

COPY index.html ./index.html

COPY package.json ./package.json

COPY tsconfig.json ./tsconfig.json
COPY config-overrides.js ./config-overrides.js
COPY tsconfig.node.json ./tsconfig.node.json

COPY vite.config.ts ./vite.config.ts

COPY public/ ./public/
COPY src/ ./src/
Expand All @@ -33,7 +50,7 @@ FROM nginx:1.21-alpine as run

RUN sed -i '/location \//a try_files $uri $uri/ /index.html;' /etc/nginx/conf.d/default.conf

COPY --from=build /usr/main/build/ /usr/share/nginx/html/
COPY --from=build /usr/main/dist/ /usr/share/nginx/html/

EXPOSE 80

Expand Down
Loading

0 comments on commit 00aa0e2

Please sign in to comment.