From 988b526018880aa8ac3dfa5706851dcfedcf42ce Mon Sep 17 00:00:00 2001 From: phutx Date: Fri, 3 May 2024 13:56:08 +0700 Subject: [PATCH] add ci/cd ibc-routing --- .github/workflows/deploy_ibc_routing.yml | 64 ++++++++++++++++++++++++ Dockerfile.ibc | 36 +++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 .github/workflows/deploy_ibc_routing.yml create mode 100644 Dockerfile.ibc diff --git a/.github/workflows/deploy_ibc_routing.yml b/.github/workflows/deploy_ibc_routing.yml new file mode 100644 index 00000000..afa58975 --- /dev/null +++ b/.github/workflows/deploy_ibc_routing.yml @@ -0,0 +1,64 @@ +name: publish_package + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the main branch + push: + tags: + - "ibc-routing[0-9]+.[0-9]+.[0-9]+" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 # Ensure using the latest release + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 # Updated to the latest version + + - name: Cache Docker layers + uses: actions/cache@v3 # Updated to the latest version + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to DockerHub + uses: docker/login-action@v2 # Updated to the latest version + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 # Updated to the latest version + with: + context: . + file: ./Dockerfile.ibc + push: true + tags: devorai/oraidex-ibc-routing:${{ github.ref_name }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + + swarm: + runs-on: orai-swarm + needs: build + steps: + - name: Deploy to Swarm + run: | + curl -X POST \ + ${{ secrets.WEBHOOK_IBC_ROUTING_SERVICE }}?tag=${{ github.ref_name }} + + - name: Send discord message + uses: appleboy/discord-action@master + with: + webhook_id: ${{ secrets.WEBHOOK_ID }} + webhook_token: ${{ secrets.WEBHOOK_TOKEN }} + username: "GitBot" + message: ":loudspeaker: Repo oraidex-sdk:ibc-routing has just deployed to swarm with tag: ${{ github.ref_name }}" diff --git a/Dockerfile.ibc b/Dockerfile.ibc new file mode 100644 index 00000000..f58f4a7c --- /dev/null +++ b/Dockerfile.ibc @@ -0,0 +1,36 @@ +# Use the official Node.js 18 image. +# https://hub.docker.com/_/node +FROM node:18.18.0 AS builder + +# Install global package +RUN yarn global add tsx tsc patch-package lerna nx + +# Create app directory. +WORKDIR /app + +# Create server folder path +RUN mkdir -p packages/ibc-routing +RUN mkdir -p packages/oraidex-common + +# Copy application dependency manifests to the container image. +# A wildcard is used to ensure both package.json AND package-lock.json are copied. +# Copying this separately prevents re-running npm install on every code change. +COPY lerna.json package.json tsconfig.json ./ +COPY packages/ibc-routing/package*.json packages/ibc-routing/tsconfig.json ./packages/ibc-routing/ +COPY packages/oraidex-common/package*.json packages/oraidex-common/tsconfig.json ./packages/oraidex-common/ + +# Install production dependencies. +RUN yarn + +# Copy local code to the container image. +COPY packages/ibc-routing/. ./packages/ibc-routing/ +COPY packages/oraidex-common/. ./packages/oraidex-common/ + +# Use the TypeScript compiler to build the application. +RUN yarn build + +# Change to the app directory. +WORKDIR /app/packages/ibc-routing + +# Run the web service on container startup. +CMD [ "yarn", "prod" ]