Skip to content

feat: 链接

feat: 链接 #5

Workflow file for this run

name: Publish Image
on:
push: # push 到主分支自动 发布
branches: ["main"]
paths-ignore: # 忽略一些不必要的文件
- ".gitignore"
- "README.md"
- ".vscode/**"
repository_dispatch:
types: [second_brain_sync]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
submodules: true
- run: |
git submodule init
git submodule update --remote
- uses: docker/login-action@v1
with:
registry: registry.cn-shanghai.aliyuncs.com # 声明镜像源
username: ${{ secrets.ALIYUN_USER }} # 当前github 用户名
password: ${{ secrets.ALIYUN_PWD }} # 需要去 https://github.com/settings/tokens 生成一个 名为 token,注意此token 需要读写 packages 等权限
- uses: actions/setup-node@v2
with:
node-version: "20.12.1"
- name: Install and Build 🔧
run: |
npm ci
npm run build
- name: Show Dir
run: ls
- name: Build the Docker image
run:
| # 使用 上一步写的 Dockerfile 构建镜像并发布到私有仓库; 发布完成可以去 https://github.com/songxingguo?tab=packages 查看
docker build . --file Dockerfile --tag registry.cn-shanghai.aliyuncs.com/songxingguo/blog:latest
docker push registry.cn-shanghai.aliyuncs.com/songxingguo/blog:latest
- name: 更新服务器
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }} # 服务器ip地址 ; 需要去仓库的 settings/secrets/actions 去创建
username: ${{ secrets.SERVER_USER }} # 服务器用户名称;需要去仓库的 settings/secrets/actions 去创建
password: ${{ secrets.SERVER_PWD }} # 服务器密码;需要去仓库的 settings/secrets/actions 去创建
port: ${{ secrets.SERVER_PORT }} # 服务器端口,默认22;需要去仓库的 settings/secrets/actions 去创建
script: | # 重启更新镜像
docker login --username=${{ secrets.ALIYUN_USER }} -p ${{ secrets.ALIYUN_PWD }} registry.cn-shanghai.aliyuncs.com
docker pull registry.cn-shanghai.aliyuncs.com/songxingguo/blog:latest
cd /root/deploy && ./deploy.sh