card-drop/.forgejo/workflows/production.yml

77 lines
2.9 KiB
YAML
Raw Normal View History

2024-04-28 17:34:42 +01:00
name: Deploy To Production
on:
push:
branches:
- main
jobs:
build:
environment: prod
2024-04-28 17:36:36 +01:00
runs-on: node
2024-04-28 17:34:42 +01:00
steps:
Update actions/checkout action to v4 (#213) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/checkout](https://github.com/actions/checkout) | action | major | `v2` -> `v4` | --- ### Release Notes <details> <summary>actions/checkout (actions/checkout)</summary> ### [`v4`](https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v414) [Compare Source](https://github.com/actions/checkout/compare/v3...v4) - Disable `extensions.worktreeConfig` when disabling `sparse-checkout` by [@&#8203;jww3](https://github.com/jww3) in https://github.com/actions/checkout/pull/1692 - Add dependabot config by [@&#8203;cory-miller](https://github.com/cory-miller) in https://github.com/actions/checkout/pull/1688 - Bump the minor-actions-dependencies group with 2 updates by [@&#8203;dependabot](https://github.com/dependabot) in https://github.com/actions/checkout/pull/1693 - Bump word-wrap from 1.2.3 to 1.2.5 by [@&#8203;dependabot](https://github.com/dependabot) in https://github.com/actions/checkout/pull/1643 ### [`v3`](https://github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v360) [Compare Source](https://github.com/actions/checkout/compare/v2...v3) - [Fix: Mark test scripts with Bash'isms to be run via Bash](https://github.com/actions/checkout/pull/1377) - [Add option to fetch tags even if fetch-depth > 0](https://github.com/actions/checkout/pull/579) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=--> Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/213 Co-authored-by: Renovate Bot <renovate@vylpes.com> Co-committed-by: Renovate Bot <renovate@vylpes.com>
2024-04-29 17:59:25 +01:00
- uses: actions/checkout@v4
2024-04-28 17:34:42 +01:00
- name: Use Node.js
Update actions/setup-node action to v4 (#214) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/setup-node](https://github.com/actions/setup-node) | action | major | `v1` -> `v4` | --- ### Release Notes <details> <summary>actions/setup-node (actions/setup-node)</summary> ### [`v4`](https://github.com/actions/setup-node/compare/v3...v4) [Compare Source](https://github.com/actions/setup-node/compare/v3...v4) ### [`v3`](https://github.com/actions/setup-node/compare/v2...v3) [Compare Source](https://github.com/actions/setup-node/compare/v2...v3) ### [`v2`](https://github.com/actions/setup-node/compare/v1...v2) [Compare Source](https://github.com/actions/setup-node/compare/v1...v2) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=--> Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/214 Co-authored-by: Renovate Bot <renovate@vylpes.com> Co-committed-by: Renovate Bot <renovate@vylpes.com>
2024-04-29 18:02:56 +01:00
uses: actions/setup-node@v4
2024-04-28 17:34:42 +01:00
with:
node-version: 20.x
2024-06-03 18:36:09 +01:00
- run: yarn install --frozen-lockfile
- run: yarn build
- run: yarn test
2024-06-03 18:43:18 +01:00
- run: yarn lint
2024-04-28 17:34:42 +01:00
- name: "Copy files over to location"
run: cp -r . ${{ secrets.PROD_REPO_PATH }}
deploy:
environment: prod
needs: build
2024-04-28 17:36:36 +01:00
runs-on: node
2024-04-28 17:34:42 +01:00
steps:
Update appleboy/ssh-action action to v1.1.0 (#374) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [appleboy/ssh-action](https://github.com/appleboy/ssh-action) | action | minor | `v1.0.3` -> `v1.1.0` | --- ### Release Notes <details> <summary>appleboy/ssh-action (appleboy/ssh-action)</summary> ### [`v1.1.0`](https://github.com/appleboy/ssh-action/releases/tag/v1.1.0) [Compare Source](https://github.com/appleboy/ssh-action/compare/v1.0.3...v1.1.0) ##### Changelog ##### Bug fixes - [`0c7561b`](https://github.com/appleboy/ssh-action/commit/0c7561b1a30e223b97730bb8b92671995d9fb1d0): fix: switch to SSH key authentication for security ([@&#8203;appleboy](https://github.com/appleboy)) ##### Enhancements - [`9b978f0`](https://github.com/appleboy/ssh-action/commit/9b978f09f2587beff9c80449f57cb0f0612d3039): chore: update SSH action version in README files ([@&#8203;appleboy](https://github.com/appleboy)) - [`1991c55`](https://github.com/appleboy/ssh-action/commit/1991c553ec29aeb9fe1cbffabfabe0c2f0ea891e): chore(file): update target file ([@&#8203;appleboy](https://github.com/appleboy)) - [`aa293c2`](https://github.com/appleboy/ssh-action/commit/aa293c24bb8b49499c238d2260b26a5ab2ee10e0): chore: optimize system configuration and API integration ([@&#8203;appleboy](https://github.com/appleboy)) - [`036cad7`](https://github.com/appleboy/ssh-action/commit/036cad7df774e9168d1de6c77d668c6a292d4540): chore: update drone-ssh to version 1.7.7 ([@&#8203;appleboy](https://github.com/appleboy)) - [`8b60782`](https://github.com/appleboy/ssh-action/commit/8b6078208d71a6d9364c7f23d78ca9b38bed48c0): chore(cli): enhance version handling and testing mechanisms ([@&#8203;appleboy](https://github.com/appleboy)) - [`5ade826`](https://github.com/appleboy/ssh-action/commit/5ade82648576fb5118b586573e9c607af4941b24): chore: improve CLI reliability and version visibility ([@&#8203;appleboy](https://github.com/appleboy)) - [`eaeb069`](https://github.com/appleboy/ssh-action/commit/eaeb06998d86f5e66259ee8dc3d0909612f0ce65): chore(cli): enhance curl command with silent mode and redirects ([@&#8203;appleboy](https://github.com/appleboy)) - [`58164d0`](https://github.com/appleboy/ssh-action/commit/58164d0dc2b76ba5c47e110152e94bfbd13ea235): chore: remove Dockerfile and related configurations ([@&#8203;appleboy](https://github.com/appleboy)) ##### Refactor - [`da612c8`](https://github.com/appleboy/ssh-action/commit/da612c801589d64bea89ca943c84fe1aae7a1d06): refactor: optimize CI pipeline for faster execution ([@&#8203;appleboy](https://github.com/appleboy)) ##### Build process updates - [`c781418`](https://github.com/appleboy/ssh-action/commit/c78141851a6d716353b2ce13c978924e0300775e): ci: enhance GitHub Actions for IPv6 and flexibility ([#&#8203;303](https://github.com/appleboy/ssh-action/issues/303)) ([@&#8203;appleboy](https://github.com/appleboy)) - [`d2d6858`](https://github.com/appleboy/ssh-action/commit/d2d68588591b705c406168accae85968a2f75c0d): ci: enhance GitHub workflow for SSH actions and deployments ([@&#8203;appleboy](https://github.com/appleboy)) - [`551964e`](https://github.com/appleboy/ssh-action/commit/551964ebda1034f0b5449d74db25c42e371ca1f7): ci: optimize GitHub Actions workflow configuration ([@&#8203;appleboy](https://github.com/appleboy)) - [`f916346`](https://github.com/appleboy/ssh-action/commit/f9163462563f649b27272d32e585525a5fe68d76): ci: refactor CI workflow and improve robustness ([#&#8203;320](https://github.com/appleboy/ssh-action/issues/320)) ([@&#8203;appleboy](https://github.com/appleboy)) - [`aabaf12`](https://github.com/appleboy/ssh-action/commit/aabaf1254d78efafd55cd5880a874e9715b4c6e8): ci: add bug report template ([@&#8203;appleboy](https://github.com/appleboy)) - [`c8594ae`](https://github.com/appleboy/ssh-action/commit/c8594ae37d5bd9a779dc12abd0236b1bcff70119): ci: implement GitHub Actions for remote SSH execution ([@&#8203;appleboy](https://github.com/appleboy)) - [`40aad53`](https://github.com/appleboy/ssh-action/commit/40aad53c5a18b2676371816d258458b2ccd56c50): ci: add SSH authentication setup for GitHub Actions ([@&#8203;appleboy](https://github.com/appleboy)) - [`0b0e770`](https://github.com/appleboy/ssh-action/commit/0b0e77098a4fa59703014092ddd6d2ad7267088f): ci: optimize and enhance SSH server workflow ([@&#8203;appleboy](https://github.com/appleboy)) - [`977b74a`](https://github.com/appleboy/ssh-action/commit/977b74a12d4201105f3b851126516847ed6b80b0): ci: enhance CI workflow with SSH job and optimizations ([@&#8203;appleboy](https://github.com/appleboy)) - [`2eeab5b`](https://github.com/appleboy/ssh-action/commit/2eeab5bdbadfcfd821c3f107a694803080f4b126): ci: refactor GitHub Actions key management ([@&#8203;appleboy](https://github.com/appleboy)) - [`acd41e5`](https://github.com/appleboy/ssh-action/commit/acd41e5091e04c5db86c78f86723e9baec27f452): ci: enhance SSH job testing with varied key/password scenarios ([@&#8203;appleboy](https://github.com/appleboy)) - [`f05aefe`](https://github.com/appleboy/ssh-action/commit/f05aefe3514f74f9cda4825a2a5d9905aa45ae2a): ci: enhance SSH action configuration and error handling ([@&#8203;appleboy](https://github.com/appleboy)) - [`e40b597`](https://github.com/appleboy/ssh-action/commit/e40b597081b0c96e4f93bee63cec35d4ea3b4d3a): ci: add GitHub Actions job for SSH key passphrase support ([@&#8203;appleboy](https://github.com/appleboy)) - [`15b64dc`](https://github.com/appleboy/ssh-action/commit/15b64dc8919f9e984dd7c4e96fdd5d74ccc03088): ci: enhance CI pipeline with SSH key handling improvements ([@&#8203;appleboy](https://github.com/appleboy)) - [`a39b3cc`](https://github.com/appleboy/ssh-action/commit/a39b3cce7dbd84fb06164ac1a60a27615417de71): ci: enhance CI/CD pipeline with SSH command execution ([@&#8203;appleboy](https://github.com/appleboy)) - [`815c574`](https://github.com/appleboy/ssh-action/commit/815c5743ac3927b147e22309d57a1f5a140a2d30): ci: enhance deployment with multi-host SSH action ([@&#8203;appleboy](https://github.com/appleboy)) - [`378323e`](https://github.com/appleboy/ssh-action/commit/378323e4c85be1bb394f07e5a3a3c7c687499829): ci: add multi-server support to CI workflow ([@&#8203;appleboy](https://github.com/appleboy)) - [`fc1c1fc`](https://github.com/appleboy/ssh-action/commit/fc1c1fce5140b0530a36d88286de8a29df8518bb): ci: add GitHub Actions job for [`ed25519`](https://github.com/appleboy/ssh-action/commit/ed25519) key support ([@&#8203;appleboy](https://github.com/appleboy)) - [`f0e5a23`](https://github.com/appleboy/ssh-action/commit/f0e5a23d530cb42b84b01340c5fb1a6ad570d4e8): ci: add environment variable handling in GitHub Actions ([@&#8203;appleboy](https://github.com/appleboy)) - [`9c32aa6`](https://github.com/appleboy/ssh-action/commit/9c32aa61f8c24f38e93a3282178429b314c14e8a): ci: refactor workflows and API integrations ([@&#8203;appleboy](https://github.com/appleboy)) - [`97f8d75`](https://github.com/appleboy/ssh-action/commit/97f8d752b568999364c7296fa08e33d68367e3fd): ci: enable root access in CI pipeline ([@&#8203;appleboy](https://github.com/appleboy)) - [`5a8776f`](https://github.com/appleboy/ssh-action/commit/5a8776fd157405e3e88da24413b04c2aaf01e99c): ci: switch to password authentication in GitHub workflow ([@&#8203;appleboy](https://github.com/appleboy)) - [`b6941ae`](https://github.com/appleboy/ssh-action/commit/b6941ae5d5746e351d7fede90e718688304d2b4a): ci: refactor codebase and optimize performance ([@&#8203;appleboy](https://github.com/appleboy)) - [`43895f2`](https://github.com/appleboy/ssh-action/commit/43895f2cd585d373b747690a3e7f9bdcdd09e1cd): ci: refactor SSH testing workflows and job configurations ([@&#8203;appleboy](https://github.com/appleboy)) - [`06fa62e`](https://github.com/appleboy/ssh-action/commit/06fa62e61cac6c39015db4efcde64776f56965c4): ci: rename the workflow files. ([@&#8203;appleboy](https://github.com/appleboy)) - [`b4a07ca`](https://github.com/appleboy/ssh-action/commit/b4a07ca5940a7dc94925e99f8e6eab3671b0fa64): ci: enhance GitHub Actions with secret variable support ([#&#8203;330](https://github.com/appleboy/ssh-action/issues/330)) ([@&#8203;appleboy](https://github.com/appleboy)) - [`25ce8cb`](https://github.com/appleboy/ssh-action/commit/25ce8cbbcb08177468c7ff7ec5cbfa236f9341e1): ci: implement automated release workflow with GoReleaser ([@&#8203;appleboy](https://github.com/appleboy)) ##### Documentation updates - [`8a779a5`](https://github.com/appleboy/ssh-action/commit/8a779a5b1a8a79465e63ce4724624b4755fed49b): docs: describe true usage of allenvs parameter ([#&#8203;301](https://github.com/appleboy/ssh-action/issues/301)) ([@&#8203;hussu010](https://github.com/hussu010)) - [`fe44be0`](https://github.com/appleboy/ssh-action/commit/fe44be0b96e09ca219322f172bc338fd0718a55b): docs: improve documentation and CI robustness ([@&#8203;appleboy](https://github.com/appleboy)) - [`dd0f09c`](https://github.com/appleboy/ssh-action/commit/dd0f09ca072e60babe3cc58ed83c66a86176300c): docs: improve README clarity and completeness ([@&#8203;appleboy](https://github.com/appleboy)) - [`71d43ea`](https://github.com/appleboy/ssh-action/commit/71d43ea0f75a1f73c9b0e4608c059783968ad29c): docs: improve documentation and testing configurations ([@&#8203;appleboy](https://github.com/appleboy)) - [`28428a1`](https://github.com/appleboy/ssh-action/commit/28428a13f5b0283d667b1c6501d144f15b059726): docs: improve cross-platform clipboard support for key copying ([@&#8203;appleboy](https://github.com/appleboy)) - [`d732991`](https://github.com/appleboy/ssh-action/commit/d732991ab09097d8c8f390d91385b0386e619598): docs(lang): README.zh-cn Document ([#&#8203;332](https://github.com/appleboy/ssh-action/issues/332)) ([@&#8203;astralwaveio](https://github.com/astralwaveio)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AiLCJsYWJlbHMiOlsidHlwZS9kZXBlbmRlbmNpZXMiXX0=--> Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/374 Reviewed-by: Vylpes <ethan@vylpes.com> Co-authored-by: Renovate Bot <renovate@vylpes.com> Co-committed-by: Renovate Bot <renovate@vylpes.com>
2024-10-08 19:35:21 +01:00
- uses: https://github.com/appleboy/ssh-action@v1.1.0
2024-04-28 17:34:42 +01:00
env:
DB_NAME: ${{ secrets.PROD_DB_NAME }}
DB_AUTH_USER: ${{ secrets.PROD_DB_AUTH_USER }}
DB_AUTH_PASS: ${{ secrets.PROD_DB_AUTH_PASS }}
DB_HOST: ${{ secrets.PROD_DB_HOST }}
DB_PORT: ${{ secrets.PROD_DB_PORT }}
DB_ROOT_HOST: ${{ secrets.PROD_DB_ROOT_HOST }}
DB_SYNC: ${{ secrets.PROD_DB_SYNC }}
DB_LOGGING: ${{ secrets.PROD_DB_LOGGING }}
DB_DATA_LOCATION: ${{ secrets.PROD_DB_DATA_LOCATION }}
SERVER_PATH: ${{ secrets.PROD_SSH_SERVER_PATH }}
BOT_TOKEN: ${{ secrets.PROD_BOT_TOKEN }}
BOT_VER: ${{ vars.PROD_BOT_VER }}
BOT_AUTHOR: ${{ vars.PROD_BOT_AUTHOR }}
BOT_OWNERID: ${{ vars.PROD_BOT_OWNERID }}
BOT_CLIENTID: ${{ vars.PROD_BOT_CLIENTID }}
BOT_ENV: ${{ vars.PROD_BOT_ENV }}
BOT_ADMINS: ${{ vars.PROD_BOT_ADMINS }}
ABOUT_FUNDING: ${{ vars.PROD_ABOUT_FUNDING }}
ABOUT_REPO: ${{ vars.PROD_ABOUT_REPO }}
DATA_DIR: ${{ secrets.PROD_DATA_DIR }}
GDRIVESYNC_AUTO: ${{ vars.PROD_GDRIVESYNC_AUTO }}
EXPRESS_PORT: ${{ secrets.PROD_EXPRESS_PORT }}
BOT_LOGLEVEL: ${{ vars.PROD_BOT_LOGLEVEL }}
BOT_LOG_DISCORD_ENABLE: ${{ vars.PROD_BOT_LOG_DISCORD_ENABLE }}
BOT_LOG_DISCORD_LEVEL: ${{ vars.PROD_BOT_LOG_DISCORD_LEVEL }}
BOT_LOG_DISCORD_WEBHOOK: ${{ secrets.PROD_BOT_LOG_DISCORD_WEBHOOK }}
BOT_LOG_DISCORD_SERVICE: ${{ vars.PROD_BOT_LOG_DISCORD_SERVICE }}
2024-04-28 17:34:42 +01:00
with:
host: ${{ secrets.PROD_SSH_HOST }}
username: ${{ secrets.PROD_SSH_USER }}
key: ${{ secrets.PROD_SSH_KEY }}
port: ${{ secrets.PROD_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,BOT_ENV,BOT_ADMINS,DATA_DIR,GDRIVESYNC_AUTO,SERVER_PATH,EXPRESS_PORT,BOT_LOGLEVEL,BOT_LOG_DISCORD_ENABLE,BOT_LOG_DISCORD_LEVEL,BOT_LOG_DISCORD_WEBHOOK,BOT_LOG_DISCORD_SERVICE
2024-04-28 17:34:42 +01:00
script: |
2024-04-28 17:40:00 +01:00
source .sshrc \
&& cd /home/vylpes/apps/card-drop/card-drop_prod \
2024-04-28 17:34:42 +01:00
&& docker compose down \
&& (pm2 stop card-drop_prod || true) \
&& (pm2 delete card-drop_prod || true) \
&& docker compose up -d \
&& sleep 10 \
&& yarn run db:up \
&& pm2 start --name card-drop_prod dist/bot.js