From 8eb12e6462a74ffef030c933c63b57ca5dba0b92 Mon Sep 17 00:00:00 2001 From: nenadmitt Date: Tue, 12 Mar 2024 21:50:28 +0100 Subject: [PATCH] gateway-production --- .github/workflows/production_build.yaml | 41 ++++++++++++++++++++++++ .github/workflows/production_deploy.yaml | 26 +++++++++++++++ .github/workflows/staging_deploy.yaml | 22 ------------- 3 files changed, 67 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/production_build.yaml create mode 100644 .github/workflows/production_deploy.yaml delete mode 100644 .github/workflows/staging_deploy.yaml diff --git a/.github/workflows/production_build.yaml b/.github/workflows/production_build.yaml new file mode 100644 index 0000000..e57c22d --- /dev/null +++ b/.github/workflows/production_build.yaml @@ -0,0 +1,41 @@ +name: Build Staging Backend +on: + push: + branches: [gateway-production] + +jobs: + build-staging-backend: + name: Service deployment + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x] + + steps: + - name: Checkount + uses: actions/checkout@v2 + + - name: Setup node and npm + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Login to container registry + uses: docker/login-action@v2 + with: + registry: ${{secrets.CONTANER_REGISTRY_URL}} + username: ${{secrets.CONTAINER_REGISTRY_KEY}} + password: ${{secrets.CONTAINER_REGISTRY_KEY}} + + - name: Build backend app + run: | + yarn install + yarn run build + + - name: Build image and push to container registry + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{secrets.CONTANER_REGISTRY_URL}}/namespace/offchain-gateway-prod:latest \ No newline at end of file diff --git a/.github/workflows/production_deploy.yaml b/.github/workflows/production_deploy.yaml new file mode 100644 index 0000000..55608c8 --- /dev/null +++ b/.github/workflows/production_deploy.yaml @@ -0,0 +1,26 @@ +name: Deploy offchain subnames api +on: + workflow_dispatch: + inputs: + version: + description: restart + default: v1.0.0 + required: true + +jobs: + restart-offchain-subnames-api: + name: Restart offchain subnames api + runs-on: ubuntu-latest + + steps: + - name: Perform restart + uses: appleboy/ssh-action@v0.1.7 + with: + host: ${{ secrets.SERVER_URL_PROD }} + username: ${{ secrets.SERVER_USER }} + key: ${{ secrets.SERVER_KEY }} + script: | + docker stop offchain-gateway + docker rm offchain-gateway + docker image pull registry.digitalocean.com/namespace/offchain-gateway-prod:latest + docker run -d -p 80:3000 --env-file prod.env --name offchain-gateway registry.digitalocean.com/namespace/offchain-gateway-prod:latest diff --git a/.github/workflows/staging_deploy.yaml b/.github/workflows/staging_deploy.yaml deleted file mode 100644 index 999b719..0000000 --- a/.github/workflows/staging_deploy.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Deploy staging api -on: - workflow_dispatch: - inputs: - version: - description: restart - default: v1.0.0 - required: true - -jobs: - restart-staging-backend: - name: Restart backend - runs-on: ubuntu-latest - - steps: - - name: Perform restart - uses: appleboy/ssh-action@v0.1.7 - with: - host: ${{ secrets.SERVER_URL }} - username: ${{ secrets.SERVER_USER }} - key: ${{ secrets.SERVER_KEY }} - script: ${{ secrets.REBUILD_CMD }} \ No newline at end of file