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: