{"id":20496,"date":"2026-06-10T11:36:58","date_gmt":"2026-06-10T03:36:58","guid":{"rendered":"https:\/\/ab123.xyz\/?p=20496"},"modified":"2026-06-10T11:36:58","modified_gmt":"2026-06-10T03:36:58","slug":"github-actions-ci-cd-for-node-js-%e5%ba%94%e7%94%a8%ef%bc%9a%e8%87%aa%e5%8a%a8%e5%8c%96%e9%83%a8%e7%bd%b2%e7%9a%84%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5","status":"publish","type":"post","link":"https:\/\/ab123.xyz\/?p=20496","title":{"rendered":"GitHub Actions CI\/CD for Node.js \u5e94\u7528\uff1a\u81ea\u52a8\u5316\u90e8\u7f72\u7684\u6700\u4f73\u5b9e\u8df5"},"content":{"rendered":"<p>\u5728\u5f53\u4eca\u5feb\u8282\u594f\u7684\u8f6f\u4ef6\u5f00\u53d1\u4e2d\uff0c\u6301\u7eed\u96c6\u6210\u4e0e\u6301\u7eed\u90e8\u7f72\uff08CI\/CD\uff09\u5df2\u6210\u4e3a\u63d0\u5347\u6548\u7387\u7684\u5173\u952e\u3002\u5bf9\u4e8e Node.js \u5e94\u7528\u5f00\u53d1\u8005\u800c\u8a00\uff0c<strong>GitHub Actions<\/strong> \u63d0\u4f9b\u4e86\u4e00\u5957\u539f\u751f\u3001\u5f3a\u5927\u4e14\u514d\u8d39\u7684\u81ea\u52a8\u5316\u5de5\u4f5c\u6d41\u89e3\u51b3\u65b9\u6848\u3002\u5b83\u5141\u8bb8\u60a8\u76f4\u63a5\u5728 GitHub \u4ed3\u5e93\u4e2d\u5b9a\u4e49\u6784\u5efa\u3001\u6d4b\u8bd5\u4e0e\u90e8\u7f72\u6d41\u7a0b\uff0c\u65e0\u9700\u989d\u5916\u642d\u5efa\u670d\u52a1\u5668\uff0c\u5373\u53ef\u5b9e\u73b0\u4ee3\u7801\u5408\u5e76\u540e\u81ea\u52a8\u8fd0\u884c\u5355\u5143\u6d4b\u8bd5\u3001\u6784\u5efa Docker \u955c\u50cf\u5e76\u63a8\u9001\u81f3\u4e91\u670d\u52a1\u5668\u3002\u8bbf\u95ee\u5b98\u65b9\u6307\u5357\uff1a<a href=\"https:\/\/docs.github.com\/en\/actions\" target=\"_blank\">\u5b98\u65b9\u7f51\u7ad9<\/a>\u3002<\/p>\n<h2>\u6838\u5fc3\u529f\u80fd\u4e0e\u4f18\u52bf<\/h2>\n<p>GitHub Actions \u652f\u6301\u4e30\u5bcc\u7684\u89e6\u53d1\u4e8b\u4ef6\uff0c\u5305\u62ec push\u3001pull request\u3001issue \u8bc4\u8bba\u7b49\uff0c\u8ba9 Node.js \u9879\u76ee\u7684 CI\/CD \u6d41\u7a0b\u9ad8\u5ea6\u7075\u6d3b\u4e14\u53ef\u5b9a\u5236\u3002<\/p>\n<ul>\n<li><strong>\u539f\u751f\u96c6\u6210<\/strong>\uff1a\u65e0\u9700\u7b2c\u4e09\u65b9\u5e73\u53f0\uff0c\u76f4\u63a5\u5728 GitHub \u4ed3\u5e93\u4e2d\u914d\u7f6e YAML \u6587\u4ef6\u5373\u53ef\u542f\u52a8\u5de5\u4f5c\u6d41\u3002<\/li>\n<li><strong>\u77e9\u9635\u6784\u5efa<\/strong>\uff1a\u53ef\u5728\u591a\u4e2a Node.js \u7248\u672c\uff08\u5982 16.x\u300118.x\u300120.x\uff09\u4e0a\u5e76\u884c\u8fd0\u884c\u6d4b\u8bd5\uff0c\u786e\u4fdd\u517c\u5bb9\u6027\u3002<\/li>\n<li><strong>\u7f13\u5b58\u52a0\u901f<\/strong>\uff1a\u81ea\u52a8\u7f13\u5b58 node_modules\uff0c\u5927\u5e45\u7f29\u77ed\u6784\u5efa\u65f6\u95f4\uff0c\u63d0\u5347\u5f00\u53d1\u4f53\u9a8c\u3002<\/li>\n<\/ul>\n<h2>\u5e94\u7528\u573a\u666f<\/h2>\n<p>\u65e0\u8bba\u662f\u4e2a\u4eba\u5f00\u6e90\u9879\u76ee\u8fd8\u662f\u4f01\u4e1a\u7ea7\u5fae\u670d\u52a1\uff0cGitHub Actions \u90fd\u80fd\u80dc\u4efb\uff1a<\/p>\n<ul>\n<li><strong>\u4ee3\u7801\u8d28\u91cf\u68c0\u67e5<\/strong>\uff1a\u6bcf\u6b21 push \u81ea\u52a8\u8fd0\u884c ESLint\u3001Prettier \u548c\u5355\u5143\u6d4b\u8bd5\uff0c\u786e\u4fdd\u4ee3\u7801\u89c4\u8303\u3002<\/li>\n<li><strong>\u81ea\u52a8\u5316\u90e8\u7f72<\/strong>\uff1a\u5408\u5e76\u5230 main \u5206\u652f\u540e\uff0c\u81ea\u52a8\u6784\u5efa Docker \u955c\u50cf\u5e76\u90e8\u7f72\u5230 AWS ECS\u3001Azure App Service \u6216\u963f\u91cc\u4e91\u3002<\/li>\n<li><strong>\u4f9d\u8d56\u66f4\u65b0\u901a\u77e5<\/strong>\uff1a\u7ed3\u5408 Dependabot \u81ea\u52a8\u521b\u5efa PR \u66f4\u65b0 npm \u5305\uff0c\u5e76\u8fd0\u884c\u6d4b\u8bd5\u9a8c\u8bc1\u53d8\u66f4\u3002<\/li>\n<\/ul>\n<h2>\u5982\u4f55\u4f7f\u7528<\/h2>\n<p>\u5728\u4ed3\u5e93\u6839\u76ee\u5f55\u521b\u5efa <code>.github\/workflows\/ci.yml<\/code> \u6587\u4ef6\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n<p>\u6b65\u9aa4\u4e00\uff1a\u5b9a\u4e49\u5de5\u4f5c\u6d41\u540d\u79f0\u4e0e\u89e6\u53d1\u4e8b\u4ef6\uff08\u5982 push \u5230 main \u5206\u652f\uff09\u3002\u6b65\u9aa4\u4e8c\uff1a\u8bbe\u7f6e jobs\uff0c\u6307\u5b9a\u8fd0\u884c\u73af\u5883\uff08ubuntu-latest\uff09\u3002\u6b65\u9aa4\u4e09\uff1a\u6dfb\u52a0 steps\uff0c\u5305\u62ec\u68c0\u51fa\u4ee3\u7801\u3001\u5b89\u88c5\u4f9d\u8d56\u3001\u8fd0\u884c\u6d4b\u8bd5\u3001\u6784\u5efa\u4ea7\u7269\u3002\u6b65\u9aa4\u56db\uff08\u53ef\u9009\uff09\uff1a\u5229\u7528 secrets \u914d\u7f6e\u4e91\u5e73\u53f0 token\uff0c\u5b9e\u73b0\u4e00\u952e\u90e8\u7f72\u3002<\/p>\n<h3>\u6700\u4f73\u5b9e\u8df5\u5efa\u8bae<\/h3>\n<ul>\n<li>\u4f7f\u7528 <code>actions\/setup-node<\/code> \u6307\u5b9a Node.js \u7248\u672c\uff0c\u4fdd\u6301\u73af\u5883\u4e00\u81f4\u6027\u3002<\/li>\n<li>\u5c06\u654f\u611f\u4fe1\u606f\uff08\u5982 API \u5bc6\u94a5\uff09\u5b58\u50a8\u5728 GitHub Secrets \u4e2d\uff0c\u907f\u514d\u786c\u7f16\u7801\u3002<\/li>\n<li>\u4e3a\u751f\u4ea7\u73af\u5883\u8bbe\u7f6e\u6279\u51c6\u4fdd\u62a4\uff0c\u9632\u6b62\u672a\u7ecf\u9a8c\u8bc1\u7684\u90e8\u7f72\u81ea\u52a8\u6267\u884c\u3002<\/li>\n<\/ul>\n<p>GitHub Actions \u6b63\u9010\u6b65\u6210\u4e3a Node.js \u793e\u533a CI\/CD \u7684\u9996\u9009\u5de5\u5177\u3002\u5b83\u964d\u4f4e\u4e86\u5165\u95e8\u95e8\u69db\uff0c\u540c\u65f6\u63d0\u4f9b\u4e86\u4f01\u4e1a\u7ea7\u7684\u5b89\u5168\u4e0e\u6269\u5c55\u80fd\u529b\u3002\u7acb\u5373\u5728\u60a8\u7684\u9879\u76ee\u4e2d\u5c1d\u8bd5\uff0c\u8ba9\u81ea\u52a8\u5316\u6d41\u6c34\u7ebf\u9a71\u52a8\u9ad8\u6548\u5f00\u53d1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5f53\u4eca\u5feb\u8282\u594f\u7684\u8f6f\u4ef6\u5f00\u53d1\u4e2d\uff0c\u6301\u7eed\u96c6\u6210\u4e0e\u6301\u7eed\u90e8\u7f72\uff08CI\/CD\uff09\u5df2\u6210\u4e3a\u63d0\u5347\u6548\u7387\u7684\u5173\u952e\u3002\u5bf9\u4e8e Node.js \u5e94\u7528\u5f00\u53d1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[23871,23872,23877],"class_list":["post-20496","post","type-post","status-publish","format-standard","hentry","category-4","tag-github-actions","tag-node-js-ci-cd","tag-23877"],"_links":{"self":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts\/20496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20496"}],"version-history":[{"count":1,"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts\/20496\/revisions"}],"predecessor-version":[{"id":20497,"href":"https:\/\/ab123.xyz\/index.php?rest_route=\/wp\/v2\/posts\/20496\/revisions\/20497"}],"wp:attachment":[{"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=20496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ab123.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=20496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}