[原创]基于阿里云nextjs项目CI/CD的完整流程
前言:最近我正在进行的《大红薯RPA》项目,这个项目主要目的是借助机器人+AI帮助用户完成重复性的工作,整个技术栈web部分,主要基于:docker / nextjs / postgres / prisma / trpc / mantine / Cloudflare CDN / authjs / redis / interaction.js
大红薯RPA服务的地址是 www.dahongshu.cn
具体每个部分是做什么的,这里就不再赘述,或者我会在其它文章详细介绍软件的架构
下面会详细介绍软件CI/CD的整个流程和细节,因为是实际使用中的相信会很有用
Create SSH Key
Login Aliyun ECS
cd /root/.ssh
ssh-keygen -m PEM -t rsa -b 4096 -C "你的git邮箱地址"
会生成私钥id_rsa,公钥id_rsa.pub
复制公钥到以下文件
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
Access https://github.com/settings/keys
Create SSH Key, 粘贴你的 private Key here
Create Action secrets and variables
Access https://github.com/[user]/[repository]/settings/secrets/actions
修改为自己的项目
- Path: Project / settings / Secrets and variables / Actions
这里准备的variables将会在你的Github Actions中访问到
准备ECS服务器
Access https://nodejs.org/en/download/package-manager
我选择使用NVM管理package
# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# download and install Node.js (you may need to restart the terminal)
nvm install 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.17.0`
# verifies the right npm version is