diff --git a/.github/workflows/deploy-dev.yaml b/.github/workflows/deploy-dev.yaml index f992fbe..7aee5e4 100644 --- a/.github/workflows/deploy-dev.yaml +++ b/.github/workflows/deploy-dev.yaml @@ -12,7 +12,6 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - CLUSTER: plugins-dev-k8s NS: plugin-fee jobs: @@ -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: | diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 18e61ad..0a12823 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,4 +1,4 @@ -name: Build and Deploy +name: Build and Push Images on: release: @@ -7,7 +7,6 @@ on: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - CLUSTER: plugins-prod-k8s NS: plugin-fee jobs: @@ -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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..eac8629 --- /dev/null +++ b/Makefile @@ -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