From 2ac2737bc0430f15ac1d4afecd5ac9d0bca740f3 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 10 Jan 2025 18:36:36 +0000 Subject: [PATCH] Add hotfix and release ci pipelines (#503) # Description Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change. #492, #493 ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provide my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://git.vylpes.xyz/RabbitLabs/vylbot-app/pulls/503 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- .forgejo/workflows/hotfix.yml | 71 ++++++++++++++++++++++++++++++++++ .forgejo/workflows/release.yml | 71 ++++++++++++++++++++++++++++++++++ .forgejo/workflows/stage.yml | 4 ++ .forgejo/workflows/test.yml | 1 - 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 .forgejo/workflows/hotfix.yml create mode 100644 .forgejo/workflows/release.yml diff --git a/.forgejo/workflows/hotfix.yml b/.forgejo/workflows/hotfix.yml new file mode 100644 index 0000000..ea16e2c --- /dev/null +++ b/.forgejo/workflows/hotfix.yml @@ -0,0 +1,71 @@ +name: Deploy Hotfix To Stage + +on: + push: + branches: + - hotfix/* + +jobs: + build: + environment: prod + + runs-on: node + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: 18.x + - run: yarn install --frozen-lockfile + - run: yarn build + - run: yarn test + + - name: "Copy files over to location" + run: cp -r . ${{ secrets.HOTFIX_REPO_PATH }} + + deploy: + environment: prod + needs: build + runs-on: node + steps: + - uses: https://github.com/appleboy/ssh-action@v1.0.0 + env: + DB_NAME: ${{ secrets.HOTFIX_DB_NAME }} + DB_AUTH_USER: ${{ secrets.HOTFIX_DB_AUTH_USER }} + DB_AUTH_PASS: ${{ secrets.HOTFIX_DB_AUTH_PASS }} + DB_HOST: ${{ secrets.HOTFIX_DB_HOST }} + DB_PORT: ${{ secrets.HOTFIX_DB_PORT }} + DB_ROOT_HOST: ${{ secrets.HOTFIX_DB_ROOT_HOST }} + DB_SYNC: ${{ secrets.HOTFIX_DB_SYNC }} + DB_LOGGING: ${{ secrets.HOTFIX_DB_LOGGING }} + DB_DATA_LOCATION: ${{ secrets.HOTFIX_DB_DATA_LOCATION }} + SERVER_PATH: ${{ secrets.HOTFIX_SSH_SERVER_PATH }} + BOT_TOKEN: ${{ secrets.HOTFIX_BOT_TOKEN }} + BOT_VER: ${{ vars.HOTFIX_BOT_VER }} + BOT_AUTHOR: ${{ vars.HOTFIX_BOT_AUTHOR }} + BOT_OWNERID: ${{ vars.HOTFIX_BOT_OWNERID }} + BOT_CLIENTID: ${{ vars.HOTFIX_BOT_CLIENTID }} + ABOUT_FUNDING: ${{ vars.HOTFIX_ABOUT_FUNDING }} + ABOUT_REPO: ${{ vars.HOTFIX_ABOUT_REPO }} + CACHE_INTERVAL: ${{ vars.HOTFIX_CACHE_INTERVAL }} + with: + host: ${{ secrets.HOTFIX_SSH_HOST }} + username: ${{ secrets.HOTFIX_SSH_USER }} + key: ${{ secrets.HOTFIX_SSH_KEY }} + port: ${{ secrets.HOTFIX_SSH_PORT }} + envs: DB_NAME,DB_AUTH_USER,DB_AUTH_PASS,DB_HOST,DB_PORT,DB_ROOT_HOST,DB_SYNC,DB_LOGGING,DB_DATA_LOCATION,BOT_TOKEN,BOT_VER,BOT_AUTHOR,BOT_OWNERID,BOT_CLIENTID,ABOUT_FUNDING,ABOUT_REPO,CACHE_INTERVAL + script: | + source .sshrc \ + && cd /home/vylpes/apps/vylbot/vylbot_hotfix \ + && docker compose down \ + && (pm2 stop vylbot_hotfix || true) \ + && (pm2 delete vylbot_hotfix || true) \ + && (pm2 stop vylbot_stage || true) \ + && (pm2 delete vylbot_stage || true) \ + && (pm2 stop vylbot_release || true) \ + && (pm2 delete vylbot_release || true) \ + && docker compose up -d \ + && sleep 10 \ + && yarn db:up \ + && pm2 start --name vylbot_hotfix dist/vylbot.js \ No newline at end of file diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..00af61f --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,71 @@ +name: Deploy Release To Stage + +on: + push: + branches: + - release/* + +jobs: + build: + environment: prod + + runs-on: node + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: 18.x + - run: yarn install --frozen-lockfile + - run: yarn build + - run: yarn test + + - name: "Copy files over to location" + run: cp -r . ${{ secrets.RELEASE_REPO_PATH }} + + deploy: + environment: prod + needs: build + runs-on: node + steps: + - uses: https://github.com/appleboy/ssh-action@v1.0.0 + env: + DB_NAME: ${{ secrets.RELEASE_DB_NAME }} + DB_AUTH_USER: ${{ secrets.RELEASE_DB_AUTH_USER }} + DB_AUTH_PASS: ${{ secrets.RELEASE_DB_AUTH_PASS }} + DB_HOST: ${{ secrets.RELEASE_DB_HOST }} + DB_PORT: ${{ secrets.RELEASE_DB_PORT }} + DB_ROOT_HOST: ${{ secrets.RELEASE_DB_ROOT_HOST }} + DB_SYNC: ${{ secrets.RELEASE_DB_SYNC }} + DB_LOGGING: ${{ secrets.RELEASE_DB_LOGGING }} + DB_DATA_LOCATION: ${{ secrets.RELEASE_DB_DATA_LOCATION }} + SERVER_PATH: ${{ secrets.RELEASE_SSH_SERVER_PATH }} + BOT_TOKEN: ${{ secrets.RELEASE_BOT_TOKEN }} + BOT_VER: ${{ vars.RELEASE_BOT_VER }} + BOT_AUTHOR: ${{ vars.RELEASE_BOT_AUTHOR }} + BOT_OWNERID: ${{ vars.RELEASE_BOT_OWNERID }} + BOT_CLIENTID: ${{ vars.RELEASE_BOT_CLIENTID }} + ABOUT_FUNDING: ${{ vars.RELEASE_ABOUT_FUNDING }} + ABOUT_REPO: ${{ vars.RELEASE_ABOUT_REPO }} + CACHE_INTERVAL: ${{ vars.RELEASE_CACHE_INTERVAL }} + with: + host: ${{ secrets.RELEASE_SSH_HOST }} + username: ${{ secrets.RELEASE_SSH_USER }} + key: ${{ secrets.RELEASE_SSH_KEY }} + port: ${{ secrets.RELEASE_SSH_PORT }} + envs: DB_NAME,DB_AUTH_USER,DB_AUTH_PASS,DB_HOST,DB_PORT,DB_ROOT_HOST,DB_SYNC,DB_LOGGING,DB_DATA_LOCATION,BOT_TOKEN,BOT_VER,BOT_AUTHOR,BOT_OWNERID,BOT_CLIENTID,ABOUT_FUNDING,ABOUT_REPO,CACHE_INTERVAL + script: | + source .sshrc \ + && cd /home/vylpes/apps/vylbot/vylbot_release \ + && docker compose down \ + && (pm2 stop vylbot_release || true) \ + && (pm2 delete vylbot_release || true) \ + && (pm2 stop vylbot_hotfix || true) \ + && (pm2 delete vylbot_hotfix || true) \ + && (pm2 stop vylbot_stage || true) \ + && (pm2 delete vylbot_stage || true) \ + && docker compose up -d \ + && sleep 10 \ + && yarn db:up \ + && pm2 start --name vylbot_release dist/vylbot.js \ No newline at end of file diff --git a/.forgejo/workflows/stage.yml b/.forgejo/workflows/stage.yml index e8157b8..372a3d6 100644 --- a/.forgejo/workflows/stage.yml +++ b/.forgejo/workflows/stage.yml @@ -61,6 +61,10 @@ jobs: && docker compose down \ && (pm2 stop vylbot_stage || true) \ && (pm2 delete vylbot_stage || true) \ + && (pm2 stop vylbot_hotfix || true) \ + && (pm2 delete vylbot_hotfix || true) \ + && (pm2 stop vylbot_release || true) \ + && (pm2 delete vylbot_release || true) \ && docker compose up -d \ && sleep 10 \ && yarn db:up \ diff --git a/.forgejo/workflows/test.yml b/.forgejo/workflows/test.yml index cf4c550..d4d6f74 100644 --- a/.forgejo/workflows/test.yml +++ b/.forgejo/workflows/test.yml @@ -4,7 +4,6 @@ on: push: branches: - feature/* - - hotfix/* - renovate/* jobs: