{"id":7036,"date":"2023-08-21T13:54:17","date_gmt":"2023-08-21T05:54:17","guid":{"rendered":"https:\/\/i007.vip:15443\/wordpress\/?p=7036"},"modified":"2023-08-21T13:54:17","modified_gmt":"2023-08-21T05:54:17","slug":"github-action","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/7036","title":{"rendered":"Github Action"},"content":{"rendered":"<p><a href=\"https:\/\/blog.csdn.net\/CSDNhuaong\/article\/details\/121414384\">cc from<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>1. Github Action \u57fa\u672c\u6982\u5ff5<br \/>\n1.1 \u4ec0\u4e48\u662f Github Action<br \/>\nAutomate your workflow from idea to production.<br \/>\nGitHub Actions makes it easy to automate all your software workflows, now with world-class CI\/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.<\/p>\n<p>Github Action\u662fGitHub \u63a8\u51fa\u7684\u6301\u7eed\u96c6\u6210 (Con\u00adtin\u00adu\u00adous in\u00adte\u00adgra\u00adtion\uff0c CI) \u670d\u52a1\uff0c\u5b83\u63d0\u4f9b\u4e86\u914d\u7f6e\u975e\u5e38\u4e0d\u9519\u7684\u865a\u62df\u670d\u52a1\u5668\u73af\u5883\uff0c\u57fa\u4e8e\u5b83\u53ef\u4ee5\u8fdb\u884c\u6784\u5efa\u3001\u6d4b\u8bd5\u3001\u6253\u5305\u3001\u90e8\u7f72\u9879\u76ee\u3002\u8ba9\u5f00\u53d1\u8005\u81ea\u52a8\u5316\u5b9e\u73b0\u5b9a\u5236\u5316\u5de5\u4f5c\u6d41\u903b\u8f91\u7684\u5e73\u53f0\uff0c\u96c6\u6210\u4e86\u6301\u7eed\u96c6\u6210\u548c\u4ea4\u4ed8\uff08CI\/CD\uff09\u529f\u80fd\uff0c\u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u81ea\u52a8\u5316\u5b8c\u6210\u4e00\u7cfb\u5217\u5de5\u4f5c\u6d41<\/p>\n<p>Github Actions \u7684\u6700\u5927\u4f18\u52bf\u5c31\u662f\u5b83\u662f\u4e0e GitHub \u9ad8\u5ea6\u6574\u5408\u7684\uff0c\u53ea\u9700\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u5373\u53ef\u81ea\u52a8\u5f00\u542f\u670d\u52a1\u3002\u751a\u81f3\u4f60\u4e0d\u9700\u8981\u8d2d\u4e70\u670d\u52a1\u5668 \u2014\u2014 GitHub Actions \u81ea\u5e26\u4e91\u73af\u5883\u8fd0\u884c\uff0c\u5305\u62ec\u79c1\u6709\u4ed3\u5e93\u4e5f\u53ef\u4ee5\u4eab\u7528\uff0c\u800c\u4e14\u4e91\u73af\u5883\u6027\u80fd\u4e5f\u975e\u5e38\u4e0d\u9519(2 cores, 7GB)\u3002<\/p>\n<p>\u80cc\u666f\uff1aCI\/CD \u5de5\u4f5c\u6d41\u7a0b<\/p>\n<p>CI (Continuous Integration)<br \/>\n\u6301\u7eed\u96c6\u6210\u6307\u7684\u662f\uff0c\u9891\u7e41\u5730\uff08\u4e00\u5929\u591a\u6b21\uff09\u5c06\u4ee3\u7801\u96c6\u6210\u5230\u4e3b\u5e72\uff0c\u6301\u7eed\u96c6\u6210\u7684\u76ee\u7684\uff0c\u5c31\u662f\u8ba9\u4ea7\u54c1\u53ef\u4ee5\u5feb\u901f\u8fed\u4ee3\uff0c\u540c\u65f6\u8fd8\u80fd\u4fdd\u6301\u9ad8\u8d28\u91cf\u3002\u5b83\u7684\u6838\u5fc3\u63aa\u65bd\u662f\uff0c\u4ee3\u7801\u96c6\u6210\u5230\u4e3b\u5e72\u4e4b\u524d\uff0c\u5fc5\u987b\u901a\u8fc7\u81ea\u52a8\u5316\u6d4b\u8bd5\u3002<\/p>\n<p>Continuous Delivery<br \/>\n\u6301\u7eed\u4ea4\u4ed8\u6307\u7684\u662f\uff0c\u9891\u7e41\u5730\u5c06\u8f6f\u4ef6\u7684\u65b0\u7248\u672c\uff0c\u4ea4\u4ed8\u7ed9\u8d28\u91cf\u56e2\u961f\u6216\u8005\u7528\u6237\uff0c\u4ee5\u4f9b\u8bc4\u5ba1\u3002\u5982\u679c\u8bc4\u5ba1\u901a\u8fc7\uff0c\u4ee3\u7801\u5c31\u8fdb\u5165\u751f\u4ea7\u9636\u6bb5\u3002 \u6301\u7eed\u4ea4\u4ed8\u53ef\u4ee5\u770b\u4f5c\u6301\u7eed\u96c6\u6210\u7684\u4e0b\u4e00\u6b65\u3002\u5b83\u5f3a\u8c03\u7684\u662f\uff0c\u4e0d\u7ba1\u600e\u4e48\u66f4\u65b0\uff0c\u8f6f\u4ef6\u662f\u968f\u65f6\u968f\u5730\u53ef\u4ee5\u4ea4\u4ed8\u7684\u3002<\/p>\n<p>Continuous Deployment<br \/>\n\u6301\u7eed\u90e8\u7f72\uff08continuous deployment\uff09\u662f\u6301\u7eed\u4ea4\u4ed8\u7684\u4e0b\u4e00\u6b65\uff0c\u6307\u7684\u662f\u4ee3\u7801\u901a\u8fc7\u8bc4\u5ba1\u4ee5\u540e\uff0c\u81ea\u52a8\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u3002\u6301\u7eed\u90e8\u7f72\u7684\u76ee\u6807\u662f\uff0c\u4ee3\u7801\u5728\u4efb\u4f55\u65f6\u523b\u90fd\u662f\u53ef\u90e8\u7f72\u7684\uff0c\u53ef\u4ee5\u8fdb\u5165\u751f\u4ea7\u9636\u6bb5\u3002<\/p>\n<p>\u57fa\u672c\u6d41\u7a0b\uff1a<\/p>\n<p>\u63d0\u4ea4commit\uff0c\u662f\u5f00\u53d1\u8005\u5411\u4ee3\u7801\u4ed3\u5e93\u63d0\u4ea4\u4ee3\u7801;<br \/>\nCI \u6d4b\u8bd5\uff1a\u4ee3\u7801\u4ed3\u5e93\u5bf9commit\u64cd\u4f5c\u914d\u7f6e\u4e86\u94a9\u5b50\uff08hook\uff09\uff0c\u53ea\u8981\u63d0\u4ea4\u4ee3\u7801\u6216\u8005\u5408\u5e76\u8fdb\u4e3b\u5e72\uff0c\u5c31\u4f1a\u8dd1\u81ea\u52a8\u5316\u6d4b\u8bd5\u3002 \u6d4b\u8bd5\u6709\u597d\u51e0\u79cd\u3002\u5355\u5143\u6d4b\u8bd5\u3001\u96c6\u6210\u6d4b\u8bd5\u3001\u7aef\u5230\u7aef\u6d4b\u8bd5<br \/>\n\u6784\u5efa\uff1a \u901a\u8fc7\u7b2c\u4e00\u8f6e\u6d4b\u8bd5\uff0c\u4ee3\u7801\u5c31\u53ef\u4ee5\u5408\u5e76\u8fdb\u4e3b\u5e72\uff0c\u4ea4\u4ed8\u540e\u5c31\u5148\u8fdb\u884c\u6784\u5efa\uff08build\uff09\uff0c\u518d\u8fdb\u5165\u7b2c\u4e8c\u8f6e\u6d4b\u8bd5\u3002\u6240\u8c13\u6784\u5efa\uff0c\u6307\u7684\u662f\u5c06\u6e90\u7801\u8f6c\u6362\u4e3a\u53ef\u4ee5\u8fd0\u884c\u7684\u5b9e\u9645\u4ee3\u7801\uff0c\u6bd4\u5982\u5b89\u88c5\u4f9d\u8d56\uff0c\u914d\u7f6e\u5404\u79cd\u8d44\u6e90\uff08\u6837\u5f0f\u8868\u3001JS\u811a\u672c\u3001\u56fe\u7247\uff09\u7b49\u7b49\u3002\u5e38\u7528\u7684\u6784\u5efa\u5de5\u5177 Jenkins\u3001Travis\u3001Codeship\u3001Strider<br \/>\n\u7b2c\u4e8c\u8f6e\u6d4b\u8bd5\uff0c \u7b2c\u4e8c\u8f6e\u662f\u5168\u9762\u6d4b\u8bd5\uff0c\u5355\u5143\u6d4b\u8bd5\u548c\u96c6\u6210\u6d4b\u8bd5\u90fd\u4f1a\u8dd1\uff0c\u6709\u6761\u4ef6\u7684\u8bdd\uff0c\u4e5f\u8981\u505a\u7aef\u5bf9\u7aef\u6d4b\u8bd5\u3002\u6240\u6709\u6d4b\u8bd5\u4ee5\u81ea\u52a8\u5316\u4e3a\u4e3b\uff0c\u5c11\u6570\u65e0\u6cd5\u81ea\u52a8\u5316\u7684\u6d4b\u8bd5\u7528\u4f8b\uff0c\u5c31\u8981\u4eba\u5de5\u8dd1\u3002<br \/>\n\u90e8\u7f72: \u901a\u8fc7\u4e86\u7b2c\u4e8c\u8f6e\u6d4b\u8bd5\uff0c\u5f53\u524d\u4ee3\u7801\u5c31\u662f\u4e00\u4e2a\u53ef\u4ee5\u76f4\u63a5\u90e8\u7f72\u7684\u7248\u672c\uff08artifact\uff09\u3002\u5c06\u8fd9\u4e2a\u7248\u672c\u7684\u6240\u6709\u6587\u4ef6\u6253\u5305\uff08 tar filename.tar * \uff09\u5b58\u6863\uff0c\u53d1\u5230\u751f\u4ea7\u670d\u52a1\u5668\u3002<br \/>\n\u56de\u6eda\uff1a\u4e00\u65e6\u5f53\u524d\u7248\u672c\u53d1\u751f\u95ee\u9898\uff0c\u5c31\u8981\u56de\u6eda\u5230\u4e0a\u4e00\u4e2a\u7248\u672c\u7684\u6784\u5efa\u7ed3\u679c\u3002\u6700\u7b80\u5355\u7684\u505a\u6cd5\u5c31\u662f\u4fee\u6539\u4e00\u4e0b\u7b26\u53f7\u94fe\u63a5\uff0c\u6307\u5411\u4e0a\u4e00\u4e2a\u7248\u672c\u7684\u76ee\u5f55<\/p>\n<p>1.2 Github Action \u6709\u4ec0\u4e48\u529f\u80fd<br \/>\n\u8de8\u5e73\u53f0\u591a\u8bed\u8a00\u652f\u6301\u7684\u6d4b\u8bd5\u73af\u5883\uff1a \u5982Linux\u3001Linux Container\u3001Windows\u3001ARM \u548c macOS \u7b49\uff0c\u5305\u62ec\u4e3b\u6d41\u7684\u5f00\u53d1\u8bed\u8a00\uff0c\u5982 Node.js\u3001Python\u3001Java\u3001PHP\u3001Ruby\u3001C\/C++\u3001.NET\uff0c\u4ee5\u53ca Android \u548c iOS \u8bbe\u5907\u4e0a\u7684\u5f00\u53d1\u8bed\u8a00<\/p>\n<p>\u81ea\u52a8\u5316\u4ee3\u7801\u6784\u5efa\u548c\u90e8\u7f72\u5de5\u4f5c\u6d41\uff1a<\/p>\n<p>\u53ef\u590d\u7528\u7684 action \u548c\u5de5\u4f5c\u6d41\u6587\u4ef6\uff1a \u57fa\u4e8e YAML \u6587\u4ef6\u6784\u5efa\u7684\uff0c\u5f00\u53d1\u8005\u53ea\u9700\u8981\u5728\u6587\u4ef6\u4e2d\u6dfb\u52a0\u51e0\u884c\u4ee3\u7801\u5c31\u53ef\u4ee5\u5b8c\u6210\u8bbe\u7f6e\uff0cGitHub Actions \u7684\u6587\u4ef6\u662f\u4ee3\u7801\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u7f16\u8f91\u3001\u590d\u7528\uff0c\u6216\u8005\u50cf fork \u4ee3\u7801\u90a3\u6837 fork \u8fd9\u4e9b\u6587\u4ef6\u3002 \u7279\u522b\u662f\u5f53\u5f00\u53d1\u8005 fork \u4e86\u4e00\u4e2a\u4ee3\u7801\u5e93\u7684\u65f6\u5019\uff0c\u5176\u4e2d\u7684 action \u4f1a\u548c\u6e90\u4ee3\u7801\u4e00\u6837\u88ab fork\u3002 \u56e0\u6b64\u5f00\u53d1\u8005\u53ef\u4ee5\u50cf\u4ee3\u7801\u63d0\u4f9b\u8005\u90a3\u6837\u8fdb\u884c\u6d4b\u8bd5\u548c\u7f16\u8bd1\u5de5\u4f5c\u3002<\/p>\n<p>\u5b9e\u65f6\u663e\u793a\u8fd0\u884c\u7ed3\u679c\uff1a\u52a8\u6001\u65e5\u5fd7\u53ef\u4ee5\u5728\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u663e\u793a\u7ed3\u679c\u3002 GitHub \u6d41\u53ef\u4ee5\u5c06\u7a0b\u5e8f\u65e5\u5fd7\u5bfc\u5165\u5230 Actions \u7684\u663e\u793a\u6846\u4e2d\uff0c\u5b9e\u65f6\u5c55\u793a\u8fd0\u884c\u8fc7\u7a0b\u3002<\/p>\n<p>\u81ea\u52a8\u6784\u5efa\u96c6\u6210\u5316\u7684\u5305\u548c\u5bb9\u5668\u5e93\uff1a\u5728\u6301\u7eed\u96c6\u6210\u548c\u90e8\u7f72\u4e2d\uff0c\u53d1\u5e03\u5305\u548c\u5bb9\u5668\u662f\u5173\u952e\u7684\u4e00\u73af\uff0c\u7279\u522b\u662f\u53d1\u5e03\u5f00\u6e90\u5e93\u6216\u90e8\u7f72\u5927\u578b\u7f51\u7edc\u670d\u52a1\u3002 GitHub Actions \u7b80\u5316\u4e86\u53d1\u5e03\u6d41\u7a0b\u3002 \u63a5\u5165 Actions \u5e73\u53f0\u7684\u5f00\u53d1\u8005\u540c\u65f6\u4e5f\u80fd\u591f\u63a5\u5165 GitHub Package Registry\uff0c\u53ef\u4ee5\u81ea\u52a8\u5316\u4ece\u6784\u5efa\u5305\u5230\u90e8\u7f72\u4e2d\u95f4\u7684\u6240\u6709\u5de5\u4f5c\u6d41\u7a0b\u3002<\/p>\n<p>1.3 \u4ec0\u4e48\u662f action<br \/>\nGithub Actions\u662f\u7531Github\u521b\u5efa\u7684 CI\/CD\u670d\u52a1\u3002 \u5b83\u7684\u76ee\u7684\u662f\u4f7f\u6240\u6709\u8f6f\u4ef6\u5f00\u53d1\u5de5\u4f5c\u6d41\u7a0b\u7684\u81ea\u52a8\u5316\u53d8\u5f97\u5bb9\u6613\u3002 \u76f4\u63a5\u4eceGitHub\u6784\u5efa\uff0c\u6d4b\u8bd5\u548c\u90e8\u7f72\u4ee3\u7801\u3002CI\uff08\u6301\u7eed\u96c6\u6210\uff09\u7531\u5f88\u591a\u64cd\u4f5c\u7ec4\u6210\uff0c\u6bd4\u5982\u4ee3\u7801\u5408\u5e76\u3001\u8fd0\u884c\u6d4b\u8bd5\u3001\u767b\u5f55\u8fdc\u7a0b\u670d\u52a1\u5668\uff0c\u53d1\u5e03\u5230\u7b2c\u4e09\u65b9\u670d\u52a1\u7b49\u7b49\u3002GitHub \u628a\u8fd9\u4e9b\u64cd\u4f5c\u5c31\u79f0\u4e3a actions\u3002<\/p>\n<p>actions\u53ef\u4ee5\u5171\u4eab\u3002GitHub \u5141\u8bb8\u5f00\u53d1\u8005\u628a\u6bcf\u4e2a\u64cd\u4f5c\u5199\u6210\u72ec\u7acb\u7684\u811a\u672c\u6587\u4ef6\uff0c\u5b58\u653e\u5230\u4ee3\u7801\u4ed3\u5e93\uff0c\u4f7f\u5f97\u5176\u4ed6\u5f00\u53d1\u8005\u53ef\u4ee5\u5f15\u7528\u3002<\/p>\n<p>2. \u5982\u4f55\u4f7f\u7528 Github Action<br \/>\n2.1 \u57fa\u672c\u6982\u5ff5<br \/>\nworkflow \uff08\u5de5\u4f5c\u6d41\u7a0b\uff09\uff1a\u6301\u7eed\u96c6\u6210\u4e00\u6b21\u8fd0\u884c\u7684\u8fc7\u7a0b<br \/>\njob \uff08\u4efb\u52a1\uff09\uff1a\u4e00\u4e2a workflow \u7531\u4e00\u4e2a\u6216\u591a\u4e2a job \u6784\u6210\uff0c\u8868\u793a\u4e00\u6b21\u6301\u7eed\u96c6\u6210\u7684\u8fd0\u884c\uff0c\u53ef\u4ee5\u5b8c\u6210\u591a\u4e2a\u4efb\u52a1<br \/>\nstep\uff08\u6b65\u9aa4\uff09\uff1a\u6bcf\u4e2a job \u7531\u591a\u4e2a step \u6784\u6210\uff0c\u4e00\u6b65\u6b65\u5b8c\u6210<br \/>\naction \uff08\u52a8\u4f5c\uff09\uff1a\u6bcf\u4e2a step \u53ef\u4ee5\u4f9d\u6b21\u6267\u884c\u4e00\u4e2a\u6216\u591a\u4e2a\u547d\u4ee4\uff08action\uff09<br \/>\n2.2 \u8d44\u6e90\u9650\u5236<br \/>\nGitHub Ac\u00adtions \u4e3a\u6bcf\u4e2a\u4efb\u52a1 (job) \u90fd\u63d0\u4f9b\u4e86\u4e00\u4e2a\u865a\u62df\u673a\u6765\u6267\u884c\uff0c\u6bcf\u53f0\u865a\u62df\u673a\u90fd\u6709\u76f8\u540c\u7684\u786c\u4ef6\u8d44\u6e90\uff1a<br \/>\n2-core CPU, 7 GB RAM \u5185\u5b58, 14 GB SSD \u786c\u76d8\u7a7a\u95f4\uff0c\u786c\u76d8\u603b\u5bb9\u91cf\u4e3a90G\u5de6\u53f3\uff0c\u53ef\u7528\u7a7a\u95f4\u4e3a30G\u5de6\u53f3\u3002<\/p>\n<p>\u6bcf\u4e2a\u4ed3\u5e93\u53ea\u80fd\u540c\u65f6\u652f\u630120\u4e2a workflow \u5e76\u884c\u3002<br \/>\n\u6bcf\u5c0f\u65f6\u53ef\u4ee5\u8c03\u75281000\u6b21 GitHub API \u3002<br \/>\n\u6bcf\u4e2a job \u6700\u591a\u53ef\u4ee5\u6267\u884c6\u4e2a\u5c0f\u65f6\u3002<br \/>\n\u514d\u8d39\u7248\u7684\u7528\u6237\u6700\u5927\u652f\u630120\u4e2a job \u5e76\u53d1\u6267\u884c\uff0cmacOS \u6700\u5927\u53ea\u652f\u63015\u4e2a\u3002<br \/>\n\u79c1\u6709\u4ed3\u5e93\u6bcf\u6708\u7d2f\u8ba1\u4f7f\u7528\u65f6\u95f4\u4e3a2000\u5206\u949f\uff0c\u8d85\u8fc7\u540e$ 0.008\/\u5206\u949f\uff0c\u516c\u5171\u4ed3\u5e93\u5219\u65e0\u9650\u5236\u3002<br \/>\n\u64cd\u4f5c\u7cfb\u7edf\u65b9\u9762\u53ef\u9009\u62e9 Win\u00addows server\u3001Linux\u3001ma\u00adcOS\uff0c\u5e76\u9884\u88c5\u4e86\u5927\u91cf\u8f6f\u4ef6\u5305\u548c\u5de5\u5177\u3002<\/p>\n<p>2.3 \u53ef\u501f\u9274\u7684 Github Actions<br \/>\nMarketplace Actions \u6709\u5404\u79cd\u7c7b\u578b\u7684Action\u53ef\u4f9b\u53c2\u8003<br \/>\nawesome-actions \u4e00\u4e2a\u53ef\u4f9b\u53c2\u8003\u7684action\u7684git\u4ed3\u5e93<br \/>\nGitHub \u505a\u4e86\u4e00\u4e2aGitHub Marketplace \uff0c\u53ef\u4ee5\u641c\u7d22\u5230\u4ed6\u4eba\u63d0\u4ea4\u7684 actions\u3002\u53e6\u5916\uff0c\u8fd8\u6709\u4e00\u4e2aAwesome Actions\u7684\u4ed3\u5e93\uff0c\u4e5f\u53ef\u4ee5\u627e\u5230\u4e0d\u5c11 action<\/p>\n<p>3. \u8bed\u6cd5\u89c4\u5219<br \/>\nAc\u00adtions \u7684\u914d\u7f6e\u6587\u4ef6\u53eb\u505a work\u00adflow \u6587\u4ef6\uff0c\u5b58\u653e\u5728\u4ee3\u7801\u4ed3\u5e93\u7684.github\/workflows \u76ee\u5f55\u4e2d<br \/>\nwork\u00adflow \u6587\u4ef6\u91c7\u7528 YAML \u683c\u5f0f\uff0c\u6587\u4ef6\u540d\u53ef\u4ee5\u4efb\u610f\u53d6\uff0c\u4f46\u662f\u540e\u7f00\u540d\u7edf\u4e00\u4e3a.yml\uff0c\u5982build.yml<br \/>\nGithub \u4f1a\u6309\u7167work\u00adflow \u6587\u4ef6\u4e2d\u6240\u6307\u5b9a\u7684\u89e6\u53d1\u6761\u4ef6\u5728\u7b26\u5408\u6761\u4ef6\u65f6\u81ea\u52a8\u8fd0\u884c\u8be5\u6587\u4ef6\u4e2d\u7684\u5de5\u4f5c\u6d41\u7a0b\u3002<br \/>\n3.1 work\u00adflow \u6587\u4ef6\u7684\u8bed\u6cd5\u89c4\u5219\uff1a<br \/>\nname \u5b57\u6bb5<br \/>\nwork\u00adflow \u7684\u540d\u79f0\u3002\u82e5\u5ffd\u7565\u6b64\u5b57\u6bb5\uff0c\u5219\u9ed8\u8ba4\u4f1a\u8bbe\u7f6e\u4e3a work\u00adflow \u6587\u4ef6\u540d\uff0c\u4e00\u822c\u8868\u793aworkflow\u7684\u529f\u80fd<\/p>\n<p># \u4e00\u822cname \u8868\u793a\u6b64 workflow\u7684\u529f\u80fd<br \/>\nname: GitHub Actions Demo<br \/>\nname: Build<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\non \u5b57\u6bb5<br \/>\n\u8868\u793awork\u00adflow \u7684\u89e6\u53d1\u6761\u4ef6\uff0c\u901a\u5e38\u662f\u67d0\u4e9b\u4e8b\u4ef6\uff0c[push, pull_request \u7b49] \u89e6\u53d1\u4e8b\u4ef6\u8be6\u7ec6\u8bed\u6cd5<\/p>\n<p>name: GitHub Actions Demo<br \/>\non: [push]<br \/>\non: [push, pull_request]<br \/>\non:<br \/>\npush:<br \/>\nbranches:<br \/>\n&#8211; main<br \/>\npull_request:<br \/>\nbranches:<br \/>\n&#8211; main<br \/>\n# Also trigger on page_build, as well as release created events<br \/>\npage_build:<br \/>\nrelease:<br \/>\ntypes: # This configuration does not affect the page_build event above<br \/>\n&#8211; created<\/p>\n<p>on:<br \/>\npush:<br \/>\npaths-ignore: ## \u4e5f\u53ef\u4ee5\u6dfb\u52a0 ignore, \u907f\u514d\u4e0d\u5fc5\u8981\u7684\u89e6\u53d1<br \/>\n&#8211; &#8216;**.md&#8217;<br \/>\n&#8211; &#8216;LICENSE&#8217;<br \/>\n&#8211; &#8216;.gitignore&#8217;<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<br \/>\n10<br \/>\n11<br \/>\n12<br \/>\n13<br \/>\n14<br \/>\n15<br \/>\n16<br \/>\n17<br \/>\n18<br \/>\n19<br \/>\n20<br \/>\n21<br \/>\n22<br \/>\njobs\u5b57\u6bb5<br \/>\n\u8868\u793a\u8981\u6267\u884c\u7684\u4e00\u9879\u6216\u591a\u9879\u4efb\u52a1\u3002\u6bcf\u4e00\u9879\u4efb\u52a1\u5fc5\u987b\u5173\u8054\u4e00\u4e2a ID\u540d\u79f0 (job_id)\uff0c\u5f53\u6709\u591a\u4e2a\u4efb\u52a1\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u4efb\u52a1\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u5373\u8fd0\u884c\u987a\u5e8f\uff0c\u5426\u5219\u662f\u540c\u65f6\u8fd0\u884c\u3002jobs\u8bed\u6cd5<\/p>\n<p>jobs:<br \/>\nmy_first_job:<br \/>\nname: My first job<br \/>\n&#8230;&#8230;.<br \/>\nmy_second_job:<br \/>\nname: My second job<br \/>\n&#8230;&#8230;<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\njob\u91cc\u7684\u5b57\u6bb5\u7684\u8bed\u6cd5\u89c4\u5219<br \/>\nruns-on \u5b57\u6bb5<br \/>\n\u6307\u5b9a\u4efb\u52a1\u8fd0\u884c\u6240\u9700\u8981\u7684\u865a\u62df\u670d\u52a1\u5668\u73af\u5883\uff0c\u662f\u5fc5\u586b\u5b57\u6bb5, runs_on\u8bed\u6cd5<\/p>\n<p>jobs:<br \/>\nExplore-GitHub-Actions:<br \/>\nruns-on: ubuntu-latest<br \/>\nsteps:<br \/>\n&#8230;&#8230;.<\/p>\n<p>other_job:<\/p>\n<p>1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\nstrategy\u5b57\u6bb5<br \/>\n\u53ef\u4ee5\u914d\u7f6estrategy.matrix\u53d8\u91cf\uff0c \u8fdb\u884c\u4e0d\u540c\u73af\u5883\u3001\u4e0d\u540c\u8bed\u8a00\u3001\u4e0d\u540c\u5de5\u5177\u7684\u591a\u4e2ajobs\u5e76\u884c\u64cd\u4f5cstategy \u8bed\u6cd5<br \/>\nfail-fast \u9ed8\u8ba4\u4e3atrue, \u53ea\u8981\u4efb\u4f55 matrix job failed, \u5219\u505c\u6389\u6240\u6709jobs<br \/>\nmax-parallel \u914d\u7f6e\u5e76\u884c jobs\u7684\u6700\u5927\u6570\u91cf<br \/>\n# strategy matrix \u793a\u4f8b<br \/>\nruns-on: ${{ matrix.os }}<br \/>\nstrategy:<br \/>\nfail-fast: false<br \/>\nmax-parallel: 2<br \/>\nmatrix:<br \/>\nos: [ubuntu-18.04, ubuntu-20.04]<br \/>\nnode: [10, 12, 14]<br \/>\nsteps:<br \/>\n&#8211; uses: actions\/setup-node@v2<br \/>\nwith:<br \/>\nnode-version: ${{ matrix.node }}<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<br \/>\n10<br \/>\n11<br \/>\n12<br \/>\nenv\u5b57\u6bb5<br \/>\n\u8bbe\u7f6e\u9002\u7528\u4e8e\u5f53\u524d job\u7684\u6240\u6709steps\u7684\u73af\u5883\u53d8\u91cf<\/p>\n<p>jobs:<br \/>\njob1:<br \/>\nenv:<br \/>\nDOCKER_IMAGE: ${{ matrix.ubuntu-version }}<br \/>\n1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\nsteps \u5b57\u6bb5<br \/>\n\u6307\u5b9a\u6bcf\u4e2a\u4efb\u52a1\u7684\u8fd0\u884c\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u6b65\u9aa4\uff08action\uff09\u3002\u6b65\u9aa4\u5f00\u5934\u4f7f\u7528 &#8211; \u7b26\u53f7\u3002\u6bcf\u4e2a\u6b65\u9aa4\u53ef\u4ee5\u6307\u5b9a\u4ee5\u4e0b\u5b57\u6bb5: steps\u8bed\u6cd5<\/p>\n<p>name\uff1a\u6b65\u9aa4\u540d\u79f0, name\u53ef\u7701\u7565<br \/>\nuses\uff1a\u8be5\u6b65\u9aa4\u5f15\u7528\u7684action\u6216 Docker \u955c\u50cf\u3002<br \/>\nrun\uff1a\u8be5\u6b65\u9aa4\u8fd0\u884c\u7684 bash \u547d\u4ee4\u3002<br \/>\nenv\uff1a\u8be5\u6b65\u9aa4\u6240\u9700\u7684\u73af\u5883\u53d8\u91cf\u3002 \u5176\u4e2d uses \u548c run \u662f\u5fc5\u586b\u5b57\u6bb5\uff0c\u6bcf\u4e2a\u6b65\u9aa4\u53ea\u80fd\u6709\u5176\u4e00\u3002\u540c\u6837\u540d\u79f0\u4e5f\u662f\u53ef\u4ee5\u5ffd\u7565\u7684\u3002<br \/>\nname: GitHub Actions Demo<br \/>\non: [push]<br \/>\njobs:<br \/>\nExplore-GitHub-Actions:<br \/>\nruns-on: ubuntu-latest<br \/>\nsteps:<br \/>\n&#8211; run: echo &#8220;? The job was automatically triggered by a ${{ github.event_name }} event.&#8221;<br \/>\n&#8211; run: echo &#8220;? This job is now running on a ${{ runner.os }} server hosted by GitHub!&#8221;<br \/>\n&#8211; run: echo &#8220;? The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}.&#8221;<br \/>\n&#8211; name: Check out repository code<br \/>\nuses: actions\/checkout@v2<br \/>\n&#8211; run: echo &#8220;? The ${{ github.repository }} repository has been cloned to the runner.&#8221;<br \/>\n&#8211; run: echo &#8220;?\ufe0f The workflow is now ready to test your code on the runner.&#8221;<br \/>\n&#8211; name: List files in the repository<br \/>\nrun: |<br \/>\nls ${{ github.workspace }}<br \/>\n&#8211; run: echo &#8220;? This job&#8217;s status is ${{ job.status }}.&#8221;<\/p>\n<p>1<br \/>\n2<br \/>\n3<br \/>\n4<br \/>\n5<br \/>\n6<br \/>\n7<br \/>\n8<br \/>\n9<br \/>\n10<br \/>\n11<br \/>\n12<br \/>\n13<br \/>\n14<br \/>\n15<br \/>\n16<br \/>\n17<br \/>\n18<br \/>\nAction \u7684\u5de5\u4f5c\u6d41\u7a0b<br \/>\n\u521b\u5efa workflow\u6587\u4ef6<br \/>\n\u6267\u884c\u76f8\u5e94\u7684git \u64cd\u4f5c\uff0c\u89e6\u53d1\u76f8\u5e94\u7684\u81ea\u52a8\u5316\u6d41\u7a0b<br \/>\n\u67e5\u770bworkflow \u7684\u6267\u884c\u7ed3\u679c<br \/>\nC++ Project Actions<br \/>\nPython Project Actions<br \/>\n\u53c2\u8003\u6587\u6863<br \/>\nGitHub Actions \u4e3b\u9875<br \/>\nGitHub Actions wiki<br \/>\nLearn GitHub Actions<\/p>\n","protected":false},"excerpt":{"rendered":"<p>cc from &nbsp; 1. Gi<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[24],"tags":[121],"class_list":["post-7036","post","type-post","status-publish","format-standard","hentry","category-value_docs","tag-05-"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/7036","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=7036"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/7036\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=7036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=7036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=7036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}