From fa57e03583a55f7563a42d497ea8281a7588efcb Mon Sep 17 00:00:00 2001 From: DaviPtrs Date: Tue, 8 Oct 2024 15:43:48 -0300 Subject: [PATCH] Refactor: move workers to another DO app --- .drone.yml | 58 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/.drone.yml b/.drone.yml index 06618af2..1837dad3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 @@ -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 @@ -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 @@ -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: @@ -122,6 +149,7 @@ trigger: - push paths: exclude: + - apps/commune-validator/** - apps/commune-governance/** - apps/commune-page/** - apps/communex-page/**