Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deployment #71

Closed
wants to merge 4 commits into from
Closed
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
17 changes: 17 additions & 0 deletions .github/workflows/PR-testnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: PR CD for Testnet graphix

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

on:
workflow_dispatch:
pull_request:

jobs:
deploy:
uses: ./.github/workflows/template-deploy.yaml
with:
ENVIRONMENT: testnet
secrets:
GCP_SECRET: ${{ secrets.GCP_GRAPH_NETWORK }}
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: CI pipeline

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

on:
push:
branches: [main]
Expand Down Expand Up @@ -33,7 +37,6 @@ jobs:
with:
command: fmt
args: --all -- --check

docker-build-and-push:
runs-on: ubuntu-latest
permissions:
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/template-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Template Deploy

on:
workflow_call:
inputs:
GCP_PROJECT_ID:
required: false
type: string
default: graph-mainnet
CLUSTER_NAME:
required: false
type: string
default: testnet
CLUSTER_LOCATION:
required: false
type: string
default: us-central1-a
ENVIRONMENT:
required: false
type: string
default: testnet
ENABLE_DIFF:
required: false
type: boolean
default: true
ENABLE_APPLY:
required: false
type: boolean
default: false
secrets:
GCP_SECRET:
required: true

jobs:
template-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v3

- id: "auth"
uses: "google-github-actions/auth@v1"
with:
credentials_json: ${{ secrets.GCP_SECRET }}

- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ inputs.GCP_PROJECT_ID }}

- id: "get-credentials"
uses: "google-github-actions/get-gke-credentials@v1"
with:
cluster_name: ${{ inputs.CLUSTER_NAME }}
location: ${{ inputs.CLUSTER_LOCATION }}

- name: Enable homebrew
uses: raviqqe/[email protected]

- name: Install infrastructure tools
run: ./brew.sh

- name: Diff ${{ inputs.ENVIRONMENT }}
if: inputs.ENABLE_DIFF
working-directory: k8s
run: kubectl diff -k ${{ inputs.ENVIRONMENT }}

- name: Deploy to ${{ inputs.ENVIRONMENT }} cluster
if: inputs.ENABLE_APPLY
working-directory: k8s
run: kubectl apply -k ${{ inputs.ENVIRONMENT }}
8 changes: 8 additions & 0 deletions brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

brew install cask google-cloud-sdk
gcloud components install gke-gcloud-auth-plugin

curl -LO "https://dl.k8s.io/release/v1.24.1/bin/linux/amd64/kubectl"
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
66 changes: 66 additions & 0 deletions k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: graphix-cross-checker
labels:
app: graphix
spec:
replicas: 1
selector:
matchLabels:
app: graphix-cross-checker
template:
metadata:
labels:
app: graphix-cross-checker
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "7300"
spec:
imagePullSecrets:
- name: docker-registry
containers:
- name: graphix
image: graphix:to-be-replaced-by-kustomize
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 80
- name: metrics
containerPort: 7300
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: graphix-api-server
labels:
app: graphix-api-server
spec:
replicas: 1
selector:
matchLabels:
app: graphix-api-server
template:
metadata:
labels:
app: graphix-api-server
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "7300"
spec:
imagePullSecrets:
- name: docker-registry
containers:
- name: api
image: api:to-be-replaced-by-kustomize
imagePullPolicy: IfNotPresent
env:
- name: GRAPHIX_DATABASE_URL
value: postgres://graphix:[email protected]:5432/graphix
ports:
- name: http
containerPort: 80
- name: metrics
containerPort: 7300
8 changes: 8 additions & 0 deletions k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- deployment.yaml
# - service.yaml
# - ingress.yaml
# - servicemonitor.yaml
13 changes: 13 additions & 0 deletions k8s/testnet/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ../base

images:
- name: graphix
newName: ghcr.io/edgeandnode/graphix-cross-checker
newTag: latest
- name: api
newName: ghcr.io/edgeandnode/graphix-api-server
newTag: latest
Loading