Skip to content
Merged
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
13 changes: 5 additions & 8 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CLUSTER: plugins-dev-k8s
NS: plugin-fee

jobs:
Expand Down Expand Up @@ -61,13 +60,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_CI_TOKEN }}

- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ env.CLUSTER }}
- name: Set up kubeconfig
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_DEV }}" > ~/.kube/config
chmod 600 ~/.kube/config

- name: Update deployment files
run: |
Expand Down
48 changes: 21 additions & 27 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy
name: Build and Push Images

on:
release:
Expand All @@ -7,7 +7,6 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CLUSTER: plugins-prod-k8s
NS: plugin-fee

jobs:
Expand Down Expand Up @@ -47,39 +46,34 @@ jobs:
tag: ${{ github.event.release.tag_name }}
additional_tag: latest

deploy:
update-manifests:
needs: [build-server, build-worker, build-tx-indexer]
runs-on: ubuntu-latest
timeout-minutes: 10

permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_CI_TOKEN }}

- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ env.CLUSTER }}
ref: main

- name: Update deployment files
- name: Update deployment files with new image tags
run: |
TAG="${{ github.event.release.tag_name }}"
sed -i "s|image: busybox|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/server:${TAG}|" deploy/01_server.yaml
sed -i "s|image: busybox|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/worker:${TAG}|" deploy/01_worker.yaml
sed -i "s|image: busybox|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/tx_indexer:${TAG}|" deploy/01_tx_indexer.yaml

- name: Deploy to Kubernetes
sed -i "s|image: ghcr.io/${{ env.IMAGE_NAME }}/server:.*|image: ghcr.io/${{ env.IMAGE_NAME }}/server:${TAG}|" deploy/01_server.yaml
sed -i "s|image: busybox|image: ghcr.io/${{ env.IMAGE_NAME }}/server:${TAG}|" deploy/01_server.yaml

sed -i "s|image: ghcr.io/${{ env.IMAGE_NAME }}/worker:.*|image: ghcr.io/${{ env.IMAGE_NAME }}/worker:${TAG}|" deploy/01_worker.yaml
sed -i "s|image: busybox|image: ghcr.io/${{ env.IMAGE_NAME }}/worker:${TAG}|" deploy/01_worker.yaml

sed -i "s|image: ghcr.io/${{ env.IMAGE_NAME }}/tx_indexer:.*|image: ghcr.io/${{ env.IMAGE_NAME }}/tx_indexer:${TAG}|" deploy/01_tx_indexer.yaml
sed -i "s|image: busybox|image: ghcr.io/${{ env.IMAGE_NAME }}/tx_indexer:${TAG}|" deploy/01_tx_indexer.yaml

- name: Commit and push updated manifests
run: |
kubectl -n ${{ env.NS }} apply -f deploy/prod
kubectl -n ${{ env.NS }} apply -f deploy/01_server.yaml
kubectl -n ${{ env.NS }} apply -f deploy/01_worker.yaml
kubectl -n ${{ env.NS }} apply -f deploy/01_tx_indexer.yaml

kubectl -n ${{ env.NS }} apply -f deploy/02_grafana_dashboard.yaml

kubectl -n ${{ env.NS }} rollout status deployment/server --timeout=300s
kubectl -n ${{ env.NS }} rollout status deployment/worker --timeout=300s
kubectl -n ${{ env.NS }} rollout status deployment/tx-indexer --timeout=300s
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add deploy/
git commit -m "chore: update image tags to ${{ github.event.release.tag_name }}" || echo "No changes to commit"
git push origin main
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.PHONY: deploy-prod deploy-server deploy-worker deploy-tx-indexer deploy-grafana

NS ?= plugin-fee

deploy-prod: deploy-configs deploy-server deploy-worker deploy-tx-indexer deploy-grafana

deploy-configs:
kubectl -n $(NS) apply -f deploy/prod

deploy-server:
kubectl -n $(NS) apply -f deploy/01_server.yaml
kubectl -n $(NS) rollout status deployment/server --timeout=300s

deploy-worker:
kubectl -n $(NS) apply -f deploy/01_worker.yaml
kubectl -n $(NS) rollout status deployment/worker --timeout=300s

deploy-tx-indexer:
kubectl -n $(NS) apply -f deploy/01_tx_indexer.yaml
kubectl -n $(NS) rollout status deployment/tx-indexer --timeout=300s

deploy-grafana:
kubectl -n $(NS) apply -f deploy/02_grafana_dashboard.yaml