{"id":17871227,"url":"https://github.com/stulzq/hexo-deploy-agent","last_synced_at":"2025-03-21T16:31:12.874Z","repository":{"id":43520032,"uuid":"511060848","full_name":"stulzq/hexo-deploy-agent","owner":"stulzq","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-07T04:51:32.000Z","size":128,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T03:05:38.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stulzq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-06T08:52:54.000Z","updated_at":"2024-08-25T22:47:34.000Z","dependencies_parsed_at":"2022-07-15T07:00:47.913Z","dependency_job_id":null,"html_url":"https://github.com/stulzq/hexo-deploy-agent","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-deploy-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-deploy-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-deploy-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stulzq%2Fhexo-deploy-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stulzq","download_url":"https://codeload.github.com/stulzq/hexo-deploy-agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244829489,"owners_count":20517309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-28T10:27:41.037Z","updated_at":"2025-03-21T16:31:12.539Z","avatar_url":"https://github.com/stulzq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hexo Deploy Agent\n\n[English](README.md)|中文\n\nHexo 部署 Agent，基于 Github Actions 可实现完全自动化部署 Hexo 博客，每次提交都会自动打包、部署、更新和刷新 CDN 缓存。\n\n特性：\n\n- 支持 Github Action 或者 Jenkins 等自动化工具\n- 通过 CURL 上传部署包\n- 解压、动态更新网站文件\n- 目录级别刷新 CDN（目前仅支持腾讯云）\n- 支持部署消息推送（目前仅支持钉钉）\n\nDemo: https://xcmaster.com/\n\n\u003e刷新 CDN 的目的：因为 hexo 是以生成静态文件部署的，CDN 默认是全部缓存了的，如果有变更需要主动刷新，一般采用目录刷新的方式。\n\n## 快速开始\n\n### 部署 Agent\n\n部署 Agent 需要虚拟机或者轻量应用服务器，支持二进制和 Docker 方式运行\n\n#### 二进制\n\n````shell\n\nexport agent_version=v0.2.0\n\nwget https://github.com/stulzq/hexo-deploy-agent/releases/download/$hexo_version/hexo_deploy_agent_$(agent_version)_linux_amd64.tar.gz\n\ntar -xzvf hexo_deploy_agent_$(agent_version)_linux_amd64.tar.gz\n\ncd hexo_deploy_agent_$(agent_version)_linux_amd64\n\n# 修改配置 conf/config.yml\n\nchmod +x hexo_deploy_agent\n./hexo_deploy_agent\n\n````\n\n#### Docker\n\n````shell\nmkdir -p /data/hexo-deploy-agent/conf\n\ncurl https://raw.githubusercontent.com/stulzq/hexo-deploy-agent/main/conf/config.yml -o /data/hexo-deploy-agent/config.yml\n\n# 修改配置 /data/hexo-deploy-agent/config.yml\n\ndocker run --name hexo-deploy-agent \\\n  -v /data/hexo-deploy-agent/conf:/app/conf \\\n  -v /data/hexo-deploy-agent/logs:/app/logs \\\n  -d stulzq/hexo-deploy-agent:v0.2.0\n\n````\n\n### 修改配置\n\n````yaml\nlog:\n  level: Debug # 日志级别\n\ndeploy:\n  blog_dir: /wwwroot/blog # 网站根目录\n  cdn:\n    enable: false # 是否启用腾讯云 cdn 目录刷新 https://console.cloud.tencent.com/cdn/refresh\n    accessKey: # 腾讯云 ak \u0026 sk https://console.cloud.tencent.com/cam/capi\n    secretKey:\n    flushType: flush\n    refreshPaths:\n      - https://xcmaster.com/ # 刷新路径\n  dingtalk:\n    enable: false # 是否发送钉钉机器人消息\n    url: # 钉钉机器人 url\n````\n\n## Github Actions 配置\n\n在你的博客根目录下新建文件夹\n\n````shell\nmkdir -p .github/workflows\ncd .github/workflows\n````\n\n新建配置文件\n\n````shell\ntouch deploy.yml\n````\n\n添加配置\n\n````yaml\nname: Deploy\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  build:\n    name: build and package\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n      - uses: actions/setup-node@v3\n        with:\n          node-version: 16\n          registry-url: https://registry.npmjs.org/\n          cache: 'npm'\n      - name: Install dependencies\n        run: npm ci\n      - name: Deploy\n        run: npm run deploy\n      - name: Package\n        run: |\n          mkdir /home/runner/work/release\n          cd public\n          zip -r /home/runner/work/release/site.zip ./*\n          cd ../\n      - name: Upload artifacts\n        uses: actions/upload-artifact@v2\n        with:\n          name: site\n          path: /home/runner/work/release\n      - name: Clean\n        run: |\n          rm -rf public\n          rm -rf /home/runner/work/release\n\n  publish:\n    name: publish blog\n    needs: build\n    runs-on: ubuntu-latest\n    steps:\n      - name: Download build artifacts\n        uses: actions/download-artifact@v1\n        with:\n          name: site\n      - name: upload\n        env:\n          UPLOAD_URL: ${{ secrets.UPLOAD_URL }}\n        run: curl -X POST -F \"f=@site/site.zip\" $UPLOAD_URL\n\n````\n\n该配置依赖 Github Action Secret\n\n![img.png](img/img.png)\n\n进入项目仓库的 `Settings -\u003e Secrets -\u003e Actions` 新建一个 Secret:\n\n- 名称： `UPLOAD_URL`\n- 值：`http://\u003cagentIp\u003e:\u003cagentPort\u003e/deploy/upload` 示例：`http://127.0.0.1:9190/deploy/upload`\n\n\u003e 可以直接使用国内云服务器，POST 部署包速度也是很快的\n\n配置完成！\n\n## 其他项目\n\n- [hexo-statistics](https://github.com/stulzq/hexo-statistics) Hexo 博客统计\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstulzq%2Fhexo-deploy-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstulzq%2Fhexo-deploy-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstulzq%2Fhexo-deploy-agent/lists"}