{"id":191,"date":"2026-07-26T21:14:44","date_gmt":"2026-07-26T13:14:44","guid":{"rendered":"https:\/\/fsdata.site\/?p=191"},"modified":"2026-07-26T22:30:23","modified_gmt":"2026-07-26T14:30:23","slug":"github-actions-deployment-automation-2","status":"publish","type":"post","link":"https:\/\/fsdata.site\/?p=191","title":{"rendered":"GitHub Actions \u90e8\u7f72\u81ea\u52a8\u5316\uff1a\u4ece Push \u5230\u4e0a\u7ebf\u53ea\u9700\u4e00\u884c"},"content":{"rendered":"<h2>\u4e3a\u4ec0\u4e48\u9009 GitHub Actions\uff1f<\/h2>\n<p>\u6bd4\u8d77 Jenkins \u548c GitLab CI\uff0cGitHub Actions \u7684\u6700\u5927\u4f18\u52bf\u662f\u96f6\u914d\u7f6e\u2014\u2014\u5b83\u76f4\u63a5\u77e5\u9053\u4ed3\u5e93\u7ed3\u6784\uff0c\u4e0d\u7528\u50cf <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/fsdata.site\/docker\u5bb9\u5668\u5316\u90e8\u7f72\u5b9e\u6218\uff1a\u4ece\u5b89\u88c5\u5230\u4e0a\u7ebf\u5168\u6d41\u7a0b\/\">Docker \u90e8\u7f72<\/a>\u90a3\u6837\u624b\u52a8\u642d\u5efa\u7f16\u6392\u7cfb\u7edf\u3002<\/p>\n<h2>.github\/workflows\/deploy.yml<\/h2>\n<pre><code class=\"language-yaml\">name: Deploy\\n\\non:\\n  push:\\n    branches: [ main ]\\n\\njobs:\\n  build-and-deploy:\\n    runs-on: ubuntu-latest\\n    steps:\\n      - uses: actions\/checkout@v4\\n      \\n      - name: Build Docker Image\\n        run: |\\n          docker build -t myapp:${{ github.sha }} .\\n          docker tag myapp:${{ github.sha }} registry.example.com\/myapp:latest\\n      \\n      - name: Deploy to Server\\n        uses: appleboy\/ssh-action@master\\n        with:\\n          host: ${{ secrets.SERVER_HOST }}\\n          username: ${{ secrets.SERVER_USER }}\\n          key: ${{ secrets.SSH_PRIVATE_KEY }}\\n          script: |\\n            docker pull registry.example.com\/myapp:latest\\n            docker stop myapp || true\\n            docker rm myapp || true\\n            docker run -d --name myapp -p 8080:8080 registry.example.com\/myapp:latest<\/code><\/pre>\n<p>\u8fd9\u5957\u6d41\u6c34\u7ebf\u4e0e <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/fsdata.site\/cicd-tools-comparison\/\">CI\/CD \u5de5\u5177\u5bf9\u6bd4<\/a>\u4e2d\u63a8\u8350\u7684\u65b9\u6848\u4e00\u81f4\u2014\u2014\u7528\u4e91\u539f\u751f\u65b9\u6848\u51cf\u5c11\u8fd0\u7ef4\u8d1f\u62c5\u3002<\/p>\n<h2>\u5173\u952e\u8981\u70b9<\/h2>\n<ol>\n<li><strong>Secrets \u7ba1\u7406<\/strong>\uff1aSSH Key\u3001Registry Token \u8d70 GitHub Secrets<\/li>\n<li><strong>\u7f13\u5b58\u52a0\u901f<\/strong>\uff1aDocker layer cache \u80fd\u7f29\u77ed\u6784\u5efa\u65f6\u95f4 60%<\/li>\n<li><strong>\u901a\u77e5\u673a\u5236<\/strong>\uff1a\u90e8\u7f72\u5b8c\u6210\u540e\u901a\u8fc7 webhook \u63a8\u9001\u5230\u9489\u9489\/\u98de\u4e66<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u6761 GitHub Actions \u6d41\u6c34\u7ebf\u4ece\u4ee3\u7801 Push \u5230\u81ea\u52a8\u90e8\u7f72\u4e0a\u7ebf\u3002\u5b8c\u6574 YAML \u914d\u7f6e + Docker \u6784\u5efa + \u591a\u73af\u5883\u5207\u6362\u5b9e\u6218\u3002<\/p>\n","protected":false},"author":2,"featured_media":207,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[21,24,25,51,71],"class_list":["post-191","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-ci-cd","tag-devops","tag-github-actions","tag-51","tag-71"],"_links":{"self":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/posts\/191","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191"}],"version-history":[{"count":4,"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions"}],"predecessor-version":[{"id":243,"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/posts\/191\/revisions\/243"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=\/wp\/v2\/media\/207"}],"wp:attachment":[{"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fsdata.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}