Skip to content

Commit

Permalink
Refactor: move workers to another DO app
Browse files Browse the repository at this point in the history
  • Loading branch information
DaviPtrs committed Oct 8, 2024
1 parent dc32a54 commit fa57e03
Showing 1 changed file with 43 additions and 15 deletions.
58 changes: 43 additions & 15 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ trigger:
---
kind: pipeline
type: docker
name: community-validator and worker
name: community-validator

steps:
- name: app-build
- name: build
image: plugins/docker
settings:
registry: ghcr.io
Expand All @@ -70,12 +70,46 @@ steps:
- ${DRONE_COMMIT_SHA:0:7}
dockerfile: docker/Dockerfile
build_args: APP_NAME=commune-validator
when:
paths:
exclude:
- apps/commune-worker/**

- name: worker-build
- name: deploy
image: digitalocean/doctl:latest
environment:
DO_CTL_TOKEN:
from_secret: DO_CTL_TOKEN
commands:
- apk add jq
- export PATH=$PATH:/app
- export COMMIT_SHORT_SHA=${DRONE_COMMIT_SHA:0:7}
- app_name=$( [ "$DRONE_BRANCH" = "main" ] && echo "community-validator" || echo "dev-community-validator" )
- app_id=$(doctl apps list -t $DO_CTL_TOKEN -o json | jq --arg name "$app_name" '.[] | select(.spec.name == $name) | .id' | tr -d '"')
- doctl apps spec get $app_id -t $DO_CTL_TOKEN > spec.yaml
- sed -i "s/\(tag:*\).*/\1 \"$COMMIT_SHORT_SHA\"/" spec.yaml
- doctl apps spec validate spec.yaml -t $DO_CTL_TOKEN --schema-only > /dev/null
- doctl apps update $app_id -t $DO_CTL_TOKEN --wait --spec spec.yaml

trigger:
branch:
- drone
- main
- dev
event:
- push
paths:
exclude:
- apps/commune-worker/**
- apps/commune-governance/**
- apps/commune-page/**
- apps/communex-page/**
- apps/sample-app/**
- apps/commune-wallet/**
- apps/commune-cache/**
---
kind: pipeline
type: docker
name: commune-worker

steps:
- name: build
image: plugins/docker
settings:
registry: ghcr.io
Expand All @@ -89,10 +123,6 @@ steps:
- ${DRONE_COMMIT_SHA:0:7}
dockerfile: docker/Dockerfile
build_args: APP_NAME=commune-worker
when:
paths:
exclude:
- apps/commune-validator/**

- name: deploy
image: digitalocean/doctl:latest
Expand All @@ -103,15 +133,12 @@ steps:
- apk add jq
- export PATH=$PATH:/app
- export COMMIT_SHORT_SHA=${DRONE_COMMIT_SHA:0:7}
- app_name=$( [ "$DRONE_BRANCH" = "main" ] && echo "community-validator" || echo "dev-community-validator" )
- app_name=$( [ "$DRONE_BRANCH" = "main" ] && echo "commune-worker" || echo "dev-commune-worker" )
- app_id=$(doctl apps list -t $DO_CTL_TOKEN -o json | jq --arg name "$app_name" '.[] | select(.spec.name == $name) | .id' | tr -d '"')
- doctl apps spec get $app_id -t $DO_CTL_TOKEN > spec.yaml
- sed -i "s/\(tag:*\).*/\1 \"$COMMIT_SHORT_SHA\"/" spec.yaml
- doctl apps spec validate spec.yaml -t $DO_CTL_TOKEN --schema-only > /dev/null
- doctl apps update $app_id -t $DO_CTL_TOKEN --wait --spec spec.yaml
depends_on:
- app-build
- worker-build

trigger:
branch:
Expand All @@ -122,6 +149,7 @@ trigger:
- push
paths:
exclude:
- apps/commune-validator/**
- apps/commune-governance/**
- apps/commune-page/**
- apps/communex-page/**
Expand Down

0 comments on commit fa57e03

Please sign in to comment.