准备工作
首先登录良心云 CloudBase,获取 Web 应用托管对应环境 ID,记录一下等会要用:
进入访问管理——访问密钥,进入到 API 密钥管理,获取 SecretId 以及 SecretKey:
登录 GitHub 并进入博客的源码库,切换到 Settings-Secrets-Actions,分别添加红框变量,如 ENVID/SECRETID/SECRETKEY:
最后切换到 Actions-New workflow-set up a workflow yourself:
数据走向
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| name: CI on: push: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: node-version: '16.17' - name: npm run: | npm i -g hexo-cli npm i - name: hexo run: hexo g --silent - name: Deploy to Tencent CloudBase uses: TencentCloudBase/cloudbase-action@v2.0.1 with: secretId: ${{secrets.secretId}} secretKey: ${{secrets.secretKey}} envId: ${{secrets.envId}}
|
注意:以上为杜老师所用代码,替换原有内容,或根据现有内容做修改即可。
文件限制
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| { "envId": "{{secrets.envId}}", "version": "2.0", "framework": { "name": "gh-actions-test", "plugins": { "func": { "use": "@cloudbase/framework-plugin-website", "inputs": { "outputPath": "public", "ignore": [ ".git", ".github", "cloudbaserc.json" ] } } } } }
|
注意:TencentCloudBase/cloudbase-action@v1
传输的文件不能超过一千,所以这里选择了 TencentCloudBase/cloudbase-action@v2.0.1
,该版本执行需要在博客源码根目录中创建文件 cloudbaserc.json
并加入上面代码。
条评论