{"id":36,"date":"2023-11-24T22:47:01","date_gmt":"2023-11-24T14:47:01","guid":{"rendered":"https:\/\/dimtechstudio.com\/?p=36"},"modified":"2025-05-10T23:56:39","modified_gmt":"2025-05-10T15:56:39","slug":"gitops-github-actions-build-and-push-docker-images","status":"publish","type":"post","link":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/","title":{"rendered":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b"},"content":{"rendered":"<p><a href=\"https:\/\/www.dimtechstudio.com\/\"><img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/DimTechStudio-Logo.png\" alt=\"DimTechStudio.Com\" \/><\/a>  <\/p>\n<h1>[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b<\/h1>\n<h2>\u5f15\u8a00<\/h2>\n<p>&emsp;&emsp;\u5f53\u4f60\u6ca1\u627e\u5230\u5408\u9002\u7684\u57fa\u7840\u7684Docker\u955c\u50cf\u65f6\uff0c\u662f\u5426\u4f1a\u4e00\u65f6\u51b2\u52a8\uff0c\u60f3\u53bb\u81ea\u5df1\u6784\u5efa\u3002\u7136\u800c\u56e0\u4e3a\u7f51\u7edc\u95ee\u9898\uff0c\u5404\u79cd\u8f6f\u4ef6\u5b98\u65b9\u6e90\u3001\u955c\u50cf\u6e90\uff08\u5305\u62ec\u4f46\u4e0d\u9650\u4e8eapt\u3001pip\u3001maven\uff0cnpm\uff09\uff0c\u4e0d\u4f46\u7f16\u8bd1\u5947\u6162\u65e0\u6bd4\uff0c\u8fd8\u65f6\u5e38\u51fa\u9519\u767d\u767d\u6d6a\u8d39\u51e0\u5341\u4e2aG\u7684\u7f51\u7edc\u6d41\u91cf\uff1b\u786c\u4ef6\u95ee\u9898\uff0c\u7231\u7528Windows\u4f46\u88c5WSL\u5f00\u4e86Hyper-V\u73a9\u4e0d\u4e86\u6a21\u62df\u5668\uff0c\u7528\u865a\u62df\u673a\u53c8\u89c9\u5f97\u9ebb\u70e6\u5360\u78c1\u76d8\u7a7a\u95f4\uff0c\u8fd8\u6ca1\u94b1\u7eed\u671f\u4e91\u670d\u52a1\u5668\u2026\u2026<br \/>\n&emsp;&emsp;\u6211\u7684\u670b\u53cb\uff0c\u5982\u679c\u4f60\u8fd8\u5728\u4e3a\u4ee5\u4e0a\u79cd\u79cd\u95ee\u9898\u800c\u82e6\u607c\uff0c\u90a3\u4e48\u6211\u5f88\u8363\u5e78\u4e3a\u4f60\u63a8\u8350<span style='color:red;'><del>Nuget<\/del><\/span> GitOps\uff0cGithub Actions!<br \/>\n&emsp;&emsp;GitOps\uff0c\u4f5c\u4e3a\u4e00\u79cd\u73b0\u4ee3\u5316\u7684\u8fd0\u7ef4\u7406\u5ff5\uff0c\u5f3a\u8c03\u901a\u8fc7\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u6765\u7ba1\u7406\u57fa\u7840\u8bbe\u65bd\u548c\u5e94\u7528\u914d\u7f6e\uff0c\u63d0\u9ad8\u53ef\u7ef4\u62a4\u6027\u548c\u53ef\u9760\u6027\u3002\u5728\u8fd9\u4e2a\u80cc\u666f\u4e0b\uff0cGithub Actions\u4f5c\u4e3a\u4e00\u9879\u5f3a\u5927\u7684CI\/CD\u5de5\u5177\uff0c\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4f18\u96c5\u7684\u89e3\u51b3\u65b9\u6848\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u5982\u4f55\u5145\u5206\u5229\u7528Github Actions\u670d\u52a1\uff0c\u767d\u5ad6\u5176\u5f3a\u5927\u7684\u6784\u5efa\u80fd\u529b\uff0c\u5b9e\u73b0Docker\u955c\u50cf\u7684\u81ea\u52a8\u6784\u5efa\u4e0e\u63a8\u9001\uff0c\u786e\u4fdd\u7f51\u7edc\u7545\u901a\u65e0\u963b\u3002<br \/>\n\u3010\u4e0d\u5f97\u4e0d\u8bf4\u540c\u6837\u662f\u5b98\u65b9\u6e90\uff0cNuget\u5c31\u6781\u5c11\u50cf\u524d\u9762\u51e0\u4e2a\u6e90\u51fa\u95ee\u9898\uff0c.net yyds\uff01\u3011  <\/p>\n<h2>Github Actions\u7b80\u4ecb<\/h2>\n<p>&emsp;&emsp;Github Actions\u662fGithub\u63d0\u4f9b\u7684\u4e00\u9879\u6301\u7eed\u96c6\u6210\u548c\u6301\u7eed\u4ea4\u4ed8\u670d\u52a1\uff0c\u4e0e\u4ed3\u5e93\u65e0\u7f1d\u96c6\u6210\uff0c\u53ef\u901a\u8fc7\u7b80\u5355\u7684YAML\u914d\u7f6e\u6587\u4ef6\u5b9a\u4e49\u5de5\u4f5c\u6d41\u7a0b\u3002\u8fd9\u4f7f\u5f97\u6211\u4eec\u80fd\u591f\u8f7b\u677e\u5730\u5728\u4ee3\u7801\u4ed3\u5e93\u4e2d\u7ba1\u7406\u548c\u6267\u884cCI\/CD\u4efb\u52a1\uff0c\u63d0\u9ad8\u5f00\u53d1\u548c\u90e8\u7f72\u7684\u6548\u7387\u3002\u501f\u52a9Github Actions\uff0c\u6211\u4eec\u53ef\u4ee5\u6784\u5efa\u3001\u6d4b\u8bd5\u548c\u90e8\u7f72\u9879\u76ee\uff0c\u5c06\u6574\u4e2a\u5f00\u53d1\u5468\u671f\u53d8\u5f97\u66f4\u52a0\u6d41\u7545\u3002<br \/>\n&emsp;&emsp;GitHub\u53ef\u4ee5\u63d0\u4f9b Linux\u3001Windows \u548c macOS \u865a\u62df\u673a\u6765\u8fd0\u884c\u4f60\u7684\u5de5\u4f5c\u6d41\u7a0b\uff0c\u5728\u4f7f\u7528Github Actions\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u4e86\u89e3\u4ee5\u4e0b\u524d\u7f6e\u77e5\u8bc6:  <\/p>\n<ul>\n<li>Yaml\u57fa\u7840\u8bed\u6cd5  <\/li>\n<li>Linux\uff08\u6216Windows\u6216macOS\uff09\u811a\u672c\u76f8\u5173\u77e5\u8bc6  <\/li>\n<li>Git\u53caGithub\u7684\u76f8\u5173\u77e5\u8bc6  <\/li>\n<\/ul>\n<h3>\u4ec0\u4e48\u662fYaml<\/h3>\n<p>&emsp;&emsp;\u5f53\u521b\u5efaGithub Actions\u65f6\uff0c\u4f1a\u5728\u4ee3\u7801\u5e93.github\/workflows\u76ee\u5f55\u4e0b\uff0c\u521b\u5efa\u4e00\u4e2a.yml \u6587\u4ef6\uff0c\u6bcf\u4e2ayml\u5bf9\u5e94\u4e00\u4e2a\u5de5\u4f5c\u6d41\u3002<br \/>\n&emsp;&emsp;YAML\uff08YAML Ain't Markup Language\u6216YAML\u662f\u4e00\u4e2a\u4eba\u7c7b\u53ef\u8bfb\u7684\u6570\u636e\u5e8f\u5217\u5316\u683c\u5f0f\uff09\u662f\u4e00\u79cd\u7b80\u6d01\u4e14\u6613\u8bfb\u7684\u6570\u636e\u6807\u8bb0\u8bed\u8a00\u3002\u5b83\u5e38\u88ab\u7528\u4e8e\u914d\u7f6e\u6587\u4ef6\u548c\u6570\u636e\u4ea4\u6362\u683c\u5f0f\uff0c\u4ee5\u4eba\u7c7b\u53ef\u8bfb\u7684\u65b9\u5f0f\u8868\u793a\u6570\u636e\u7ed3\u6784\uff0c\u6709\u4ee5\u4e0b\u51e0\u4e2a\u7279\u70b9:  <\/p>\n<ul>\n<li>\u5927\u5c0f\u5199\u654f\u611f\u3002  <\/li>\n<li>\u4f7f\u7528\u7f29\u8fdb\u8868\u793a\u5c42\u7ea7\u5173\u7cfb\u3002  <\/li>\n<li>\u7f29\u8fdb\u53ea\u80fd\u4f7f\u7528\u7a7a\u683c\uff0c\u4e0d\u80fd\u7528 TAB \u5b57\u7b26\u3002  <\/li>\n<li>\u7f29\u8fdb\u7684\u7a7a\u683c\u6570\u91cf\u4e0d\u91cd\u8981\uff0c\u53ea\u8981\u5c42\u7ea7\u76f8\u540c\u7684\u5143\u7d20\u5de6\u5bf9\u9f50\u5373\u53ef\u3002  <\/li>\n<li>\n<h1>\u8868\u793a\u6ce8\u91ca\u3002<\/h1>\n<\/li>\n<\/ul>\n<h3>Github Actions\u7684Yaml\u7ed3\u6784<\/h3>\n<ul>\n<li>name\uff1aworkflow\u540d\u79f0  <\/li>\n<li>on\uff1a\u89e6\u53d1\u5668  <\/li>\n<li>env\uff1a\u81ea\u5b9a\u4e49\u7684\u73af\u5883\u53d8\u91cf  <\/li>\n<li>job\uff1a\u4e00\u4e2aworkflow\u53ef\u4ee5\u6709\u591a\u4e2ajob\uff0c\u6bcf\u4e2ajob\u5305\u542b\u591a\u4e2astep  <\/li>\n<li>runs-on\uff1a\u4efb\u52a1\u5bb9\u5668\uff0c\u5982ubuntu-latest\uff0cwindows-latest\uff0cmacos-latest  <\/li>\n<li>step\uff1a\u4efb\u52a1\u6b65\u9aa4  <\/li>\n<li>action\uff1a\u6bcf\u4e2a\u6b65\u9aa4\u53ef\u4ee5\u6267\u884c\u591a\u4e2a\u547d\u4ee4  <\/li>\n<\/ul>\n<h3>Github Actions\u7684\u4f7f\u7528\u9650\u5236<\/h3>\n<p>&emsp;&emsp;Github Actions\u53ef\u4ee5\u514d\u8d39\u4f7f\u7528\uff0c\u4e5f\u53ef\u4ee5\u4ed8\u8d39\u4f7f\u7528\uff0c\u5176\u4e2d\u514d\u8d39\u7528\u6237\u6709\u4ee5\u4e0b\u9650\u5236\uff1a  <\/p>\n<ul>\n<li>\u4f7f\u7528\u65f6\u957f<br \/>\n\u53ef\u4ee5\u6bcf\u6708\u4f7f\u75282000\u5206\u949f\uff0c\u5b58\u50a8500MB\uff08\u5e94\u8be5\u662f\u6307\u4ed3\u5e93\u5927\u5c0f\uff09\uff0c\u5176\u4e2d\u4e0d\u540c\u5bb9\u5668\u65f6\u95f4\u7cfb\u6570\u662f\u4e0d\u540c\u7684\uff0cLinux\u662f1\uff0cWindows\u662f2\uff081000\u5206\u949f\uff09\uff0cMacOS\u662f10\uff08200\u5206\u949f\uff09\uff1b  <\/li>\n<li>\u5e76\u53d1\u4f5c\u4e1a\u657020  <\/li>\n<li>\u4f5c\u4e1a\u6267\u884c\u65f6\u95f4\u6700\u957f6\u5c0f\u65f6  <\/li>\n<li>\u5de5\u4f5c\u6d41\u8fd0\u884c\u65f6\u95f4\u6bcf\u6b21\u5de5\u4f5c\u6d41\u8fd0\u884c\u65f6\u95f4\u9650\u5236\u4e3a 35 \u5929<br \/>\n\uff08\u7b14\u8005\u6ca1\u770b\u61c2\u8fd9\u9879\u76ee\uff09  <\/li>\n<\/ul>\n<p>&emsp;&emsp;\u66f4\u8be6\u7ec6\u5185\u5bb9\u53ef\u4ee5\u5728\u5b98\u7f51\u4e2d\u627e\u5230<a href=\"https:\/\/docs.github.com\/zh\/actions\/learn-github-actions\/usage-limits-billing-and-administration\">usage-limits-billing-and-administration<\/a>  <\/p>\n<h2>Docker\u955c\u50cf\u7684\u6784\u5efa<\/h2>\n<p>&emsp;&emsp;\u5728Github Actions\u4e2d\u914d\u7f6eDocker\u955c\u50cf\u6784\u5efa\u7684\u8fc7\u7a0b\u975e\u5e38\u7b80\u5355\u3002\u901a\u8fc7\u5b9a\u4e49workflow\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u89e6\u53d1\u6761\u4ef6\u3001\u6784\u5efa\u6b65\u9aa4\u548c\u4f9d\u8d56\u5173\u7cfb\u3002\u914d\u7f6e\u4e00\u4e2a\u6784\u5efa\u6b65\u9aa4\uff0c\u6267\u884cDocker\u955c\u50cf\u7684\u6784\u5efa\uff0c\u786e\u4fdd\u5728\u6bcf\u6b21\u4ee3\u7801\u63a8\u9001\u65f6\u89e6\u53d1\u81ea\u52a8\u6784\u5efa\u6d41\u7a0b\u3002\u8fd9\u79cd\u81ea\u52a8\u5316\u7684\u6784\u5efa\u6d41\u7a0b\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u6548\u7387\uff0c\u8fd8\u51cf\u5c11\u4e86\u4eba\u4e3a\u51fa\u9519\u7684\u53ef\u80fd\u6027\u3002  <\/p>\n<h3>\u65b0\u5efaworkflow<\/h3>\n<p>&emsp;&emsp;\u9996\u5148\u6253\u5f00\u4f60\u7684Github \u4ee3\u7801\u5e93\uff0c\u70b9\u51fbActions<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/442624416231165.png\" alt=\"\" \/><br \/>\n&emsp;&emsp;\u70b9\u51fbNew workflow\u6309\u94ae<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/372014516249591.png\" alt=\"\" \/>  <\/p>\n<p>&emsp;&emsp;\u641c\u7d22Docker\uff0c\u4f1a\u6709\u5f88\u591aworkflow\u6a21\u677f\uff0c\u5176\u4e2dDocker Image\u662f\u975e\u5e38\u7b80\u6d01\u7684\u6a21\u677f\uff0c\u9002\u5408\u7b14\u8005\u6211\u8fd9\u79cd\u7b80\u7ea6\u4e3b\u4e49\u8005\uff0c\u4ee5\u4e0b\u5c06\u4f7f\u7528\u5b83\u4f5c\u4e3a\u6559\u7a0b\u793a\u4f8b\u3002<br \/>\n<mark>\u987a\u5e26\u4e00\u63d0\uff0c\u9694\u58c1\u90a3\u4e2a\u6a21\u677f\u5f88\u590d\u6742\u2026\u2026\u82f1\u6587\u597d\u7684\u4eba\u53ef\u4ee5\u7814\u7a76\u7814\u7a76<\/mark><br \/>\n&emsp;&emsp;\u70b9\u51fbConfigure\uff0c\u8fdb\u5165\u7f16\u5199yml\uff0c\u7f16\u5199\u4efb\u52a1<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/354134616237458.png\" alt=\"\" \/>  <\/p>\n<p>&emsp;&emsp;\u5b98\u65b9\u9ed8\u8ba4\u6a21\u677f\u5185\u5bb9\u5982\u4e0b\uff0c\u529f\u80fd\u662f\u5f53push\u6216\u8005pull master\u5206\u652f\u65f6\uff0c\u89e6\u53d1\u6784\u5efa\u6d41\u7a0b  <\/p>\n<pre><code class=\"language-yaml\">name: Docker Image CI\non:\n  push:\n    branches: [ &quot;master&quot; ]\n  pull_request:\n    branches: [ &quot;master&quot; ]\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions\/checkout@v3\n    - name: Build the Docker image\n      run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)<\/code><\/pre>\n<p>&emsp;&emsp;\u800crun\u6807\u7b7e\uff0c\u5c31\u662flinux\u4e0b\u7684shell\u811a\u672c\uff0c\u65e2\u7136\u662fshell\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u505a\u5f88\u591a\u4e8b\u60c5\u4e86\u3002<br \/>\n&emsp;&emsp;\u6bd4\u5982\u8bf4\u4f60\u539f\u672c\u5df2\u6709\u4e00\u5957\u6784\u5efa\u811a\u672c(build.sh)\uff0c\u90a3\u4e48\u53ef\u80fd\u7a0d\u4f5c\u4fee\u6539\uff0c\u5c31\u80fd\u7528\u7740Github Actions\u4e2d\uff0crun\u6539\u4e3ash build.sh\u5373\u53ef\u3002<br \/>\n&emsp;&emsp;yml\u53ef\u4ee5\u5728\u7ebf\u7f16\u8f91\uff0c\u4e5f\u53ef\u4ee5\u4fdd\u5b58\u540epull\u5230\u672c\u5730\u4ee3\u7801\u5e93\u3002  <\/p>\n<h3>\u793a\u4f8b\u4ee3\u7801\u5e93<\/h3>\n<p>&emsp;&emsp;\u56de\u5230\u524d\u8a00\u6240\u8bf4\u7684\u5185\u5bb9\uff0c\u7b14\u8005\u75db\u70b9\u662f\u5e0c\u671b\u627e\u4e00\u4e2a\u4eba\u5de5\u667a\u80fd\u7684\u8fd0\u884c\u73af\u5883\u955c\u50cf\uff0c\u4f46\u6ca1\u6709\u6574\u5408\u7684\uff0c\u4eba\u5de5\u667a\u80fd\u7684\u955c\u50cf\u4e00\u822c\u53c8\u5f88\u5927\uff0c\u5404\u73af\u5883\u5355\u72ec\u4e00\u4e2a\u955c\u50cf\u4e0b\u8f7d\u6162\u53c8\u5360\u7a7a\u95f4\uff0c\u5728whl\u5305\u4e0d\u51b2\u7a81\u7684\u60c5\u51b5\u4e0b\uff0c\u88c5\u5728\u4e00\u8d77\u80fd\u7701\u5f88\u591a\u63a7\u4ef6\uff0c\u4e8e\u662f\u4e4e\u5c31\u8bde\u751f\u4e86\u672c\u9879\u76ee\uff1a<a href=\"https:\/\/github.com\/DimWalker\/Wlkr.DockerBuild\">Wlkr.DockerBuild<\/a><br \/>\n\u6ce8\u610f\uff0c\u672c\u9879\u76ee\u76ee\u7684\u662f\u7f16\u8bd1\u57fa\u7840\u73af\u5883\u7684\u955c\u50cf\uff0c\u6ca1\u6709\u4ec0\u4e48\u4ee3\u7801\uff0c\u53ef\u80fd\u5e38\u89c1\u7684\u9879\u76ee\u5f00\u53d1\u6709\u6240\u51fa\u5165\uff0c\u8bf7\u81ea\u884c\u7504\u9009\u3002  <\/p>\n<p>&emsp;&emsp;\u89c2\u5bdfWlkr.AiRuntime\u9879\u76ee\uff0c\u4f1a\u89c1\u5230\u6709\u591a\u4e2a Dockfile\uff0c\u6b64\u4e3e\u662f\u4e3a\u4e86\u907f\u514d\u7f16\u8bd1\u5931\u8d25\uff0c\u5bfc\u81f4\u6f2b\u957f\u7684\u6784\u5efa\u8fc7\u7a0b\u53c8\u8981\u91cd\u65b0\u7f16\u8bd1\u3002<br \/>\n&emsp;&emsp;\u6bd4\u5982Ubuntu\u955c\u50cf\u9ed8\u8ba4\u6ca1\u6709python\uff0c\u9664\u4e86python\u8fd8\u6709\u5176\u4ed6\u4e00\u4e9b\u6df1\u5ea6\u5b66\u4e60\u6240\u9700\u7684\u57fa\u7840\u7ec4\u4ef6\u4e5f\u6ca1\u6709\uff0c\u5f53\u4f60\u7f16\u8bd1\u901a\u8fc7python\u540e\uff0c\u5b89\u88c5pytorch\u62a5\u9519\u7f3a\u5931\u7ec4\u4ef6\uff0c\u89c4\u5212\u4e0d\u597d\u53c8\u8981\u4ecepython\u90a3\u4e2a\u6b65\u9aa4\u5f00\u53d1\u7f16\u8bd1\uff0c\u975e\u5e38\u6d6a\u8d39\u65f6\u95f4\u3002<br \/>\n&emsp;&emsp;\u5728\u5206\u800c\u6cbb\u4e4b\u7684\u601d\u60f3\u6307\u5bfc\u4e0b\uff0c \u6700\u7ec8\u955c\u50cf\u6784\u5efa\u5206\u4e3a\u4e867\u4e2aDockerfile\u3002  <\/p>\n<h3>\u89e6\u53d1\u5668<\/h3>\n<p>&emsp;&emsp;\u4fee\u6539\u5de5\u4f5c\u6d41\u7684yml\uff0c\u6539\u4e3a\u76d1\u542c\u8fd97\u4e2aDockerfile\u548c\u4e00\u4e2apython\u6587\u4ef6  <\/p>\n<pre><code class=\"language-yaml\">name: Docker Image CI\non:\n  push:\n    # \u76d1\u542c\u7684\u5206\u652f\n    branches:\n      - master\n    # \u76d1\u542c\u7684\u6587\u4ef6\n    paths:\n      - &#039;Wlkr.AiRuntime\/Dockerfile*&#039;\n      - &#039;Wlkr.AiRuntime\/model_init.py&#039;<\/code><\/pre>\n<p>&emsp;&emsp;\u5982\u679c\u4f60\u5728\u81ea\u5df1\u7684linux\u670d\u52a1\u5668\u4e0b\u7f16\u8bd1\u8fc7docker\u955c\u50cf\uff0cDockerfile\u4e2d\u7f16\u8bd1\u6210\u529f\u7684\u6b65\u9aa4\u4f1a\u6709\u4e00\u4e2a\u7f13\u5b58layer\uff0c\u51cf\u5c11\u7f16\u8bd1\u7684\u6240\u9700\u65f6\u95f4\u3002<br \/>\n&emsp;&emsp;\u4f46\u662f\u5728Github Actions\u4e2d\uff0c\u6bcf\u6b21\u6267\u884c\u5de5\u4f5c\u6d41\uff0c\u5747\u6ca1\u6709\u7f13\u5b58\u3002<br \/>\n\u540c\u65f6\u7b14\u8005\u6240\u7f16\u8bd1\u7684\u955c\u50cf\u662f\u73af\u73af\u76f8\u6263\u7684\uff0c\u4e0a\u4e00\u5c42\u955c\u50cf\u6709\u6539\u52a8\u65f6\uff0c\u4e0b\u5c42\u7684\u6240\u6709\u955c\u50cf\u4e5f\u5e94\u8be5\u91cd\u65b0\u7f16\u8bd1\u3002  <\/p>\n<h3>\u4f18\u5316\u6784\u5efa\u6d41\u7a0b<\/h3>\n<p>&emsp;&emsp;\u6709\u6ca1\u6709\u4f18\u5316\u7684\u53ef\u80fd\uff1f\u7b54\u6848\u662f\u6709\u7684\uff01<br \/>\n&emsp;&emsp;\u5148\u5b9a\u4e497\u4e2aflag\u53d8\u91cf  <\/p>\n<pre><code class=\"language-yaml\">env:\n  flag_python: 0\n  flag_pytorch: 0\n  flag_modelscope: 0\n  flag_modelscope_cv: 0\n  flag_mscv_pd: 0\n  flag_mscv_pdocr: 0\n  flag_mscv_pdocr_mdl: 0\n  flag_done: 0<\/code><\/pre>\n<p>&emsp;&emsp;\u4fee\u6539\u62c9\u53d6\u4ee3\u7801\u7684action\uff0c\u9ed8\u8ba4\u4f1a\u5e26\u4e0a\u53c2\u6570--dept=1\uff0c\u65e0\u6cd5\u6ee1\u8db3\u540e\u7eed\u7684\u64cd\u4f5c  <\/p>\n<pre><code class=\"language-yaml\">jobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n    - name: Checkout Code\n      uses: actions\/checkout@v3\n      with:\n        fetch-depth: 2 #\u52a0\u4e0a\u8fd9\u4e2a\u53c2\u6570<\/code><\/pre>\n<p>&emsp;&emsp;\u5728\u4e0a\u9762\u76d1\u542c\u6587\u4ef6\u4e2d\uff0c\u6211\u4eec\u76d1\u542c\u4e86\u6240\u6709Dockerfile\uff0c\u663e\u7136\u6ca1\u6709\u53d8\u52a8\u7684Dockerfile\uff0c\u662f\u4e0d\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\u91cd\u65b0\u6784\u5efa\u7684\u3002<br \/>\n&emsp;&emsp;\u90a3\u4e48\u600e\u4e48\u77e5\u9053\u54ea\u4e9b\u6587\u4ef6\u6709\u53d8\u52a8\uff0c\u54ea\u4e2a\u955c\u50cf\u9700\u8981\u91cd\u65b0\u7f16\u8bd1\uff1f\u7b54\u6848\u5c31\u662fcommit\u540e\u4ea7\u751f\u7684sha id\u3002<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/122213817257624.png\" alt=\"\" \/><br \/>\n&emsp;&emsp;\u5229\u7528<code>git diff<\/code>\u547d\u4ee4\uff0c\u68c0\u67e5\u4e0a\u4e00\u6b21commit\u4e0e\u672c\u6b21commit\u7684\u6587\u4ef6\u662f\u5426\u4e0d\u540c\uff0c\u5982\u679c\u4e0d\u5bb9\uff0c\u5219\u4fee\u6539flag\uff0c\u6807\u8bb0\u4e3a\u9700\u8981\u7f16\u8bd1\u3002  <\/p>\n<pre><code class=\"language-yaml\">    - name: Check Modify\n      run: |\n        echo &quot;previous_sha=${{ github.event.before }}&quot;\n\n        cd Wlkr.AiRuntime\n        # python\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.python)&quot; ]; then\n          echo &quot;flag_python=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        # \u5176\u4ed6flag\u7701\u7565<\/code><\/pre>\n<p>&emsp;&emsp;\u5728\u6784\u5efa\u7684action\u4e2d\uff0c\u52a0\u4e0a\u6dfb\u52a0<code>if: env.flag_python == 1<\/code>\uff0c\u6765\u786e\u5b9a\u662f\u5426\u8981\u6267\u884c\u7f16\u8bd1\uff0c\u5982\u679c\u8981\u5219\u5c06\u4e0b\u4e00\u6b65\u9aa4\u7684flag\u4e5f\u6539\u4e3a1\u3002  <\/p>\n<pre><code class=\"language-yaml\">    - name: Build python\n      if: env.flag_python == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.python -t dimwalker\/wlkr.python .\n        echo &quot;flag_pytorch=1&quot; &gt;&gt; $GITHUB_ENV<\/code><\/pre>\n<p>&emsp;&emsp;\u81f3\u6b64\uff0c\u7f16\u8bd1\u7684\u4f18\u5316\u5df2\u5b8c\u6210\u3002<br \/>\n&emsp;&emsp;\u9700\u8981\u6ce8\u610f\uff0c\u6bcf\u4e2aaction\u90fd\u662f\u72ec\u7acb\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\u5de5\u4f5c\u76ee\u5f55<code>cd Wlkr.AiRuntime<\/code>\u8981\u5728\u6bcf\u4e2astep\u4e2d\u5148\u8fd0\u884c\u4e00\u6b21\u3002  <\/p>\n<h2>Docker\u955c\u50cf\u7684\u63a8\u9001<\/h2>\n<p>&emsp;&emsp;Docker Hub\u4f5c\u4e3a\u4e00\u4e2a\u5e7f\u6cdb\u4f7f\u7528\u7684Docker\u955c\u50cf\u4ed3\u5e93\uff0c\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4fbf\u6377\u7684\u955c\u50cf\u5b58\u50a8\u548c\u5206\u4eab\u5e73\u53f0\u3002\u901a\u8fc7Github Actions\uff0c\u6211\u4eec\u53ef\u4ee5\u914d\u7f6e\u81ea\u52a8\u5c06\u6784\u5efa\u597d\u7684Docker\u955c\u50cf\u63a8\u9001\u5230Docker Hub\u3002\u8fd9\u4e00\u6b65\u9aa4\u4f7f\u5f97\u6211\u4eec\u7684\u5e94\u7528\u5728\u6784\u5efa\u5b8c\u6210\u540e\uff0c\u80fd\u591f\u8fc5\u901f\u88ab\u90e8\u7f72\u548c\u5171\u4eab\uff0c\u4e3a\u56e2\u961f\u534f\u4f5c\u548c\u6301\u7eed\u96c6\u6210\u63d0\u4f9b\u4e86\u66f4\u591a\u53ef\u80fd\u6027\u3002<br \/>\n&emsp;&emsp;\u5728\u6784\u5efa\u548c\u63a8\u9001Docker\u955c\u50cf\u7684\u8fc7\u7a0b\u4e2d\uff0c\u7f51\u7edc\u901a\u4fe1\u53ef\u80fd\u4f1a\u6210\u4e3a\u4e00\u4e2a\u6f5c\u5728\u7684\u95ee\u9898\u3002\u4e3a\u4e86\u786e\u4fdd\u7545\u901a\u65e0\u963b\uff0c\u6211\u4eec\u53ef\u4ee5\u91c7\u53d6\u4e00\u7cfb\u5217\u63aa\u65bd\uff0c\u5982\u914d\u7f6e\u5408\u9002\u7684\u7f51\u7edc\u4ee3\u7406\u3001\u4f18\u5316\u955c\u50cf\u6784\u5efa\u6b65\u9aa4\u3001\u4ee5\u53ca\u5408\u7406\u9009\u62e9\u6784\u5efa\u548c\u63a8\u9001\u7684\u65f6\u673a\u3002\u8fd9\u4e9b\u63aa\u65bd\u5c06\u6709\u52a9\u4e8e\u63d0\u9ad8\u6784\u5efa\u6210\u529f\u7387\uff0c\u786e\u4fdd\u6574\u4e2a\u6d41\u7a0b\u7684\u987a\u7545\u8fdb\u884c\u3002<br \/>\n&emsp;&emsp;\u4f46\u5728\u5927\u5c40\u57df\u7f51\u4e2d\uff0c\u4f9d\u7136\u5bf8\u6b65\u96be\u884c\u3002\u800c\u4f60\u53ea\u9700\u5c06\u6784\u5efa\u6b65\u9aa4\u79fb\u5230Github Actions\u4e2d\uff0c\u4e00\u5207\u95ee\u9898\u90fd\u80fd\u8fce\u5203\u800c\u89e3\uff0c\u771f\u9999\uff01  <\/p>\n<blockquote>\n<p>\u6709\u4e00\u70b9\u9700\u8981\u6ce8\u610f\uff0c\u867d\u7136Github\u548cDocker Hub\u5f88\u9999\uff0c\u4f46\u662fDocker Hub\u7684\u955c\u50cf\u65f6\u5f00\u6e90\u7684\uff01\u6709\u5546\u7528\u3001\u6d89\u5bc6\u7b49\u4f7f\u7528\u8981\u6c42\u7684\u4eba\uff0c\u8bf7\u8c28\u614e\u4f7f\u7528\u3002  <\/p>\n<\/blockquote>\n<h3>\u767b\u5f55Docker Hub<\/h3>\n<p>&emsp;&emsp;\u73b0\u5728\u5148\u56de\u5230Github Actions\u7684workflow\u7f16\u8f91\u9875\u9762\uff0c\u5b83\u7684\u53f3\u8fb9\u4e5f\u662f\u6709\u5f88\u591aaction\u6a21\u677f\u7684\uff01<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/546684817250293.png\" alt=\"\" \/><br \/>\n&emsp;&emsp;\u628aDocker login\u7684\u4ee3\u7801\u590d\u5236\u8fdb\u4f60\u7684workflow yml\u4e2d\uff0c\u653e\u5728steps\u9760\u524d\u7684\u4f4d\u7f6e<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/22125317246848.png\" alt=\"\" \/><br \/>\n&emsp;&emsp;\u4fdd\u7559\u793a\u4f8b\u4e2d\u7684\u4e09\u4e2a\u53c2\u6570\u5373\u53ef<br \/>\n&emsp;&emsp;\u5176\u4e2d\u5728<code>env<\/code>\u8282\u70b9\u52a0\u4e0a\u53d8\u8138<code>REGISTRY<\/code>\uff0c\u7559\u7a7a\u662f\u5c06\u955c\u50cf\u63a8\u9001\u5230docker hub\u4e2d\uff0c\u5982\u679c\u662f\u5176\u4ed6\u5e93\u5219\u586b\u76f8\u5e94\u7684\u5730\u5740  <\/p>\n<pre><code>    - name: Docker Login\n      uses: docker\/login-action@v3.0.0\n      with:\n        registry: ${{ env.REGISTRY }}\n        username: ${{ secrets.DOCKERACC }}\n        password: ${{ secrets.DOCKERPWD }}<\/code><\/pre>\n<p><code>DOCKERACC<\/code>\u548c<code>DOCKERPWD<\/code>\u5219\u9700\u8981\u5728\u4ee3\u7801\u5e93\u4e2d\u7684settings\u91cc\u8bbe\u7f6e\u3002<br \/>\n&emsp;&emsp;\u6309\u7167docker\u5b98\u7f51\u8bf4\u6cd5\uff0c\u8fd9\u7684PWD\u4e5f\u53ef\u4ee5\u662f\u4f60\u8bbe\u7f6e\u7684\u4e00\u4e2atoken\uff0c\u591a\u4eba\u534f\u4f5c\u5c31\u4e0d\u6015\u5bc6\u7801\u6cc4\u9732\u7684\u98ce\u9669<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/272835817242602.png\" alt=\"\" \/>  <\/p>\n<h3>\u63a8\u9001Docker\u955c\u50cf<\/h3>\n<p>&emsp;&emsp;\u5f88\u7b80\u5355\uff0c\u7a0d\u5fae\u4fee\u6539\u6784\u5efa\u7684\u6b65\u9aa4\uff0c\u589e\u52a0\u4f9d\u636e<code>push<\/code>\u547d\u4ee4\u5373\u53ef  <\/p>\n<pre><code class=\"language-yaml\">    - name: Build &amp; Push python\n      if: env.flag_python == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.python -t dimwalker\/wlkr.python .\n        docker push dimwalker\/wlkr.python:latest\n        echo &quot;flag_pytorch=1&quot; &gt;&gt; $GITHUB_ENV<\/code><\/pre>\n<h2>\u5b8c\u6574\u7684yml<\/h2>\n<p>&emsp;&emsp;\u4f60\u6ca1\u731c\u9519\uff0c\u8fd9\u6bb5\u5c31\u662f\u7528\u6765\u6c34\u5b57\u6570\u7684\u3002  <\/p>\n<pre><code class=\"language-yaml\">name: Docker Image CI\n\non:\n  push:\n    # \u76d1\u542c\u7684\u5206\u652f\n    branches:\n      - master\n    # \u76d1\u542c\u7684\u6587\u4ef6\n    paths:\n      - &#039;Wlkr.AiRuntime\/Dockerfile*&#039;\n      - &#039;Wlkr.AiRuntime\/model_init.py&#039;\nenv:\n  # Use docker.io for Docker Hub if empty\n  REGISTRY: &#039;&#039;\n  flag_python: 0\n  flag_pytorch: 0\n  flag_modelscope: 0\n  flag_modelscope_cv: 0\n  flag_mscv_pd: 0\n  flag_mscv_pdocr: 0\n  flag_mscv_pdocr_mdl: 0\n  flag_done: 0\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n\n    steps:\n    - name: Checkout Code\n      uses: actions\/checkout@v3\n      with:\n        fetch-depth: 2\n\n    - name: Docker Login\n      uses: docker\/login-action@v3.0.0\n      with:\n        registry: ${{ env.REGISTRY }}\n        username: ${{ secrets.DOCKERACC }}\n        password: ${{ secrets.DOCKERPWD }}\n\n    - name: Check Modify\n      run: |\n        echo &quot;previous_sha=${{ github.event.before }}&quot;\n\n        cd Wlkr.AiRuntime\n        # python\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.python)&quot; ]; then\n          echo &quot;flag_python=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        # pytorch\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.pytorch)&quot; ]; then\n          echo &quot;flag_pytorch=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        # modelscope\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.modelscope)&quot; ]; then\n          echo &quot;flag_modelscope=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        #\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.modelscope_cv)&quot; ]; then\n          echo &quot;flag_modelscope_cv=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        # mscv_pd\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.mscv_pd)&quot; ]; then\n          echo &quot;flag_mscv_pd=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        # mscv_pdocr\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.mscv_pdocr)&quot; ]; then\n          echo &quot;flag_mscv_pdocr=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        # mscv_pdocr_mdl\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- Dockerfile.mscv_pdocr_mdl)&quot; ]; then\n          echo &quot;flag_mscv_pdocr_mdl=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n        if [ -n &quot;$(git diff --name-only ${{ github.event.before }} HEAD -- model_init.py)&quot; ]; then\n          echo &quot;flag_mscv_pdocr_mdl=1&quot; &gt;&gt; $GITHUB_ENV\n        fi\n\n    - name: Print Env\n      run: |\n        echo &quot;flag_python: ${{ env.flag_python }}&quot;\n        echo &quot;flag_pytorch: ${{ env.flag_pytorch }}&quot;\n        echo &quot;flag_modelscope: ${{ env.flag_modelscope }}&quot;\n        echo &quot;flag_modelscope_cv: ${{ env.flag_modelscope_cv }}&quot;\n        echo &quot;flag_mscv_pd: ${{ env.flag_mscv_pd }}&quot;\n        echo &quot;flag_mscv_pdocr: ${{ env.flag_mscv_pdocr }}&quot;\n        echo &quot;flag_mscv_pdocr_mdl: ${{ env.flag_mscv_pdocr_mdl }}&quot;\n\n    - name: Build &amp; Push python\n      if: env.flag_python == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.python -t dimwalker\/wlkr.python .\n        docker push dimwalker\/wlkr.python:latest\n        echo &quot;flag_pytorch=1&quot; &gt;&gt; $GITHUB_ENV\n\n    - name: Build &amp; Push pytorch\n      if: env.flag_pytorch == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.pytorch -t dimwalker\/wlkr.pytorch .\n        docker push dimwalker\/wlkr.pytorch:latest\n        echo &quot;flag_modelscope=1&quot; &gt;&gt; $GITHUB_ENV\n\n    - name: Build &amp; Push modelscope\n      if: env.flag_modelscope == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.modelscope -t dimwalker\/wlkr.modelscope .\n        docker push dimwalker\/wlkr.modelscope:latest\n        echo &quot;flag_modelscope_cv=1&quot; &gt;&gt; $GITHUB_ENV\n\n    - name: Build &amp; Push modelscope_cv\n      if: env.flag_modelscope_cv == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.modelscope_cv -t dimwalker\/wlkr.modelscope_cv .\n        docker push dimwalker\/wlkr.modelscope_cv:latest\n        echo &quot;flag_mscv_pd=1&quot; &gt;&gt; $GITHUB_ENV\n\n    - name: Build &amp; Push mscv_pd\n      if: env.flag_mscv_pd == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.mscv_pd -t dimwalker\/wlkr.mscv_pd .\n        docker push dimwalker\/wlkr.mscv_pd:latest\n        echo &quot;flag_mscv_pdocr=1&quot; &gt;&gt; $GITHUB_ENV\n\n    - name: Build &amp; Push mscv_pdocr\n      if: env.flag_mscv_pdocr == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.mscv_pdocr -t dimwalker\/wlkr.mscv_pdocr .\n        docker push dimwalker\/wlkr.mscv_pdocr:latest\n        echo &quot;flag_mscv_pdocr_mdl=1&quot; &gt;&gt; $GITHUB_ENV\n\n    - name: Build &amp; Push mscv_pdocr_mdl\n      if: env.flag_mscv_pdocr_mdl == 1\n      run: |\n        cd Wlkr.AiRuntime\n        # \u57fa\u7840\n        docker build -f Dockerfile.mscv_pdocr_mdl -t dimwalker\/wlkr.mscv_pdocr_mdl .\n        docker push dimwalker\/wlkr.mscv_pdocr_mdl:latest\n        echo &quot;flag_done=1&quot; &gt;&gt; $GITHUB_ENV\n\n    - name: Print Env End\n      run: |\n        echo &quot;flag_python: ${{ env.flag_python }}&quot;\n        echo &quot;flag_pytorch: ${{ env.flag_pytorch }}&quot;\n        echo &quot;flag_modelscope: ${{ env.flag_modelscope }}&quot;\n        echo &quot;flag_modelscope_cv: ${{ env.flag_modelscope_cv }}&quot;\n        echo &quot;flag_mscv_pd: ${{ env.flag_mscv_pd }}&quot;\n        echo &quot;flag_mscv_pdocr: ${{ env.flag_mscv_pdocr }}&quot;\n        echo &quot;flag_mscv_pdocr_mdl: ${{ env.flag_mscv_pdocr_mdl }}&quot;\n        echo &quot;flag_done: ${{ env.flag_done }}&quot;<\/code><\/pre>\n<p>&emsp;&emsp;Well Done\uff01<br \/>\n<img decoding=\"async\" src=\"\/dimwalker\/Wlkr.MyNote\/raw\/master\/2023\/11\/24\/vx_images\/145601018260482.png\" alt=\"\" \/>  <\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>&emsp;&emsp;\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u6df1\u5165\u63a2\u8ba8\u4e86\u5982\u4f55\u5145\u5206\u53d1\u6325 GitHub Actions \u5728 GitOps \u4e2d\u7684\u4f5c\u7528\uff0c\u7279\u522b\u662f\u5728\u6784\u5efa\u548c\u63a8\u9001 Docker \u955c\u50cf\u65b9\u9762\u3002\u901a\u8fc7 GitHub Actions\uff0c\u5f00\u53d1\u8005\u80fd\u591f\u5145\u5206\u5229\u7528\u4e91\u7aef\u8d44\u6e90\uff0c\u8f7b\u677e\u5b9e\u73b0 CI\/CD \u6d41\u7a0b\u3002<br \/>\n&emsp;&emsp;\u901a\u8fc7\u914d\u7f6e GitHub Actions \u7684\u5de5\u4f5c\u6d41\u7a0b\uff0c\u6211\u4eec\u53ef\u4ee5\u786e\u4fdd\u6784\u5efa\u548c\u63a8\u9001 Docker \u955c\u50cf\u7684\u6d41\u7a0b\u7545\u901a\u65e0\u963b\u3002\u8fd9\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u5f00\u53d1\u56e2\u961f\u7684\u6548\u7387\uff0c\u8fd8\u964d\u4f4e\u4e86\u51fa\u9519\u7684\u53ef\u80fd\u6027\uff0c\u4f7f\u6574\u4e2a\u5f00\u53d1\u8fc7\u7a0b\u66f4\u52a0\u53ef\u9760\u548c\u53ef\u9884\u6d4b\u3002<br \/>\n&emsp;&emsp;\u603b\u7684\u6765\u8bf4\uff0cGitHub Actions\u4f5c\u4e3a\u4e00\u4e2a\u96c6\u6210\u4e8eGitHub\u5e73\u53f0\u7684CI\/CD\u5de5\u5177\uff0c\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u5f3a\u5927\u800c\u7075\u6d3b\u7684\u5de5\u5177\uff0c\u652f\u6301\u4ed6\u4eec\u6784\u5efa\u51fa\u9ad8\u8d28\u91cf\u7684\u8f6f\u4ef6\u3002\u5c24\u5176\u662f\u5bf9\u4e8e Docker \u955c\u50cf\u7684\u6784\u5efa\u548c\u63a8\u9001\uff0cGitHub Actions \u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u65b9\u5f0f\uff0c\u4f7f\u5f00\u53d1\u8005\u80fd\u591f\u4e13\u6ce8\u4e8e\u4ee3\u7801\u672c\u8eab\u800c\u4e0d\u5fc5\u8fc7\u591a\u5173\u5fc3\u5e95\u5c42\u7684\u90e8\u7f72\u7ec6\u8282\u3002<br \/>\n&emsp;&emsp;\u9664\u4e86Github Actions\uff0c\u7b14\u8005\u4ee5\u5f80\u8fd8\u4f7f\u7528\u8fc7Webhooks+Jenkins\u7684\u65b9\u5f0f\uff0c\u5728\u81ea\u5df1\u7684\u4e91\u7aef\u670d\u52a1\u5668\u7f16\u8bd1\u955c\u50cf\u3002\u672a\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u671f\u5f85 GitOps \u5728\u6301\u7eed\u96c6\u6210\u3001\u6301\u7eed\u90e8\u7f72\u9886\u57df\u7684\u8fdb\u4e00\u6b65\u6f14\u8fdb\u3002\u968f\u7740\u4e91\u539f\u751f\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u8fd9\u4e9b\u5de5\u5177\u5c06\u66f4\u52a0\u8d34\u8fd1\u5f00\u53d1\u8005\u7684\u9700\u6c42\uff0c\u63d0\u4f9b\u66f4\u591a\u521b\u65b0\u7684\u529f\u80fd\uff0c\u5e2e\u52a9\u5f00\u53d1\u56e2\u961f\u66f4\u597d\u5730\u5e94\u5bf9\u5feb\u901f\u53d8\u5316\u7684\u8f6f\u4ef6\u4ea4\u4ed8\u9700\u6c42\u3002  <\/p>\n","protected":false},"excerpt":{"rendered":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b \u5f15\u8a00 &emsp;&emsp;\u5f53\u4f60\u6ca1\u627e\u5230\u5408\u9002\u7684\u57fa\u7840\u7684Docker\u955c\u50cf\u65f6\uff0c\u662f\u5426\u4f1a\u4e00\u65f6\u51b2\u52a8\uff0c\u60f3\u53bb\u81ea\u5df1\u6784\u5efa\u3002\u7136 &#8230;","protected":false},"author":1,"featured_media":14,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[9,11,12,10,8],"class_list":["post-36","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gitops","category-3","tag-devops","tag-docker","tag-docker-hub","tag-github-actions","tag-gitops"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b - \u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b - \u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8\" \/>\n<meta property=\"og:description\" content=\"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b \u5f15\u8a00 &emsp;&emsp;\u5f53\u4f60\u6ca1\u627e\u5230\u5408\u9002\u7684\u57fa\u7840\u7684Docker\u955c\u50cf\u65f6\uff0c\u662f\u5426\u4f1a\u4e00\u65f6\u51b2\u52a8\uff0c\u60f3\u53bb\u81ea\u5df1\u6784\u5efa\u3002\u7136 ...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/\" \/>\n<meta property=\"og:site_name\" content=\"\u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-24T14:47:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-10T15:56:39+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/dimtechstudio.com\/wp-content\/uploads\/2023\/11\/DimTechStudio-Logo-220x150-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"220\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"DimWalker\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"DimWalker\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/\"},\"author\":{\"name\":\"DimWalker\",\"@id\":\"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8\"},\"headline\":\"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b\",\"datePublished\":\"2023-11-24T14:47:01+00:00\",\"dateModified\":\"2025-05-10T15:56:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/\"},\"wordCount\":326,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8\"},\"keywords\":[\"DevOps\",\"Docker\",\"Docker Hub\",\"Github Actions\",\"GitOps\"],\"articleSection\":[\"GitOps\",\"\u539f\u521b\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/\",\"url\":\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/\",\"name\":\"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b - \u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8\",\"isPartOf\":{\"@id\":\"http:\/\/dimtechstudio.com\/#website\"},\"datePublished\":\"2023-11-24T14:47:01+00:00\",\"dateModified\":\"2025-05-10T15:56:39+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/dimtechstudio.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/dimtechstudio.com\/#website\",\"url\":\"http:\/\/dimtechstudio.com\/\",\"name\":\"\u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8\",\"description\":\"DimTechStudio\",\"publisher\":{\"@id\":\"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/dimtechstudio.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8\",\"name\":\"DimWalker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/dimtechstudio.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/dimtechstudio.com\/wp-content\/uploads\/2023\/11\/DimTechStudio-Icon-128x128-1.png\",\"contentUrl\":\"http:\/\/dimtechstudio.com\/wp-content\/uploads\/2023\/11\/DimTechStudio-Icon-128x128-1.png\",\"width\":128,\"height\":128,\"caption\":\"DimWalker\"},\"logo\":{\"@id\":\"http:\/\/dimtechstudio.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/dimtechstudio.com\"],\"url\":\"http:\/\/dimtechstudio.com\/index.php\/author\/walker\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b - \u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/","og_locale":"zh_CN","og_type":"article","og_title":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b - \u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8","og_description":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b \u5f15\u8a00 &emsp;&emsp;\u5f53\u4f60\u6ca1\u627e\u5230\u5408\u9002\u7684\u57fa\u7840\u7684Docker\u955c\u50cf\u65f6\uff0c\u662f\u5426\u4f1a\u4e00\u65f6\u51b2\u52a8\uff0c\u60f3\u53bb\u81ea\u5df1\u6784\u5efa\u3002\u7136 ...","og_url":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/","og_site_name":"\u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8","article_published_time":"2023-11-24T14:47:01+00:00","article_modified_time":"2025-05-10T15:56:39+00:00","og_image":[{"width":220,"height":150,"url":"http:\/\/dimtechstudio.com\/wp-content\/uploads\/2023\/11\/DimTechStudio-Logo-220x150-1.png","type":"image\/png"}],"author":"DimWalker","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"DimWalker","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#article","isPartOf":{"@id":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/"},"author":{"name":"DimWalker","@id":"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8"},"headline":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b","datePublished":"2023-11-24T14:47:01+00:00","dateModified":"2025-05-10T15:56:39+00:00","mainEntityOfPage":{"@id":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/"},"wordCount":326,"commentCount":0,"publisher":{"@id":"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8"},"keywords":["DevOps","Docker","Docker Hub","Github Actions","GitOps"],"articleSection":["GitOps","\u539f\u521b"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/","url":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/","name":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b - \u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8","isPartOf":{"@id":"http:\/\/dimtechstudio.com\/#website"},"datePublished":"2023-11-24T14:47:01+00:00","dateModified":"2025-05-10T15:56:39+00:00","breadcrumb":{"@id":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/dimtechstudio.com\/index.php\/2023\/11\/24\/gitops-github-actions-build-and-push-docker-images\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/dimtechstudio.com\/"},{"@type":"ListItem","position":2,"name":"[GitOps] \u767d\u5ad6\u795e\u5668Github Actions\uff0c\u6784\u5efa\u3001\u63a8\u9001Docker\u955c\u50cf\u4e00\u8def\u7545\u901a\u65e0\u963b"}]},{"@type":"WebSite","@id":"http:\/\/dimtechstudio.com\/#website","url":"http:\/\/dimtechstudio.com\/","name":"\u9eef\u5f71\u4fe1\u606f\u79d1\u6280\u90e8","description":"DimTechStudio","publisher":{"@id":"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/dimtechstudio.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/dimtechstudio.com\/#\/schema\/person\/7f8c70f133a3ce4b0c308884bbbd83a8","name":"DimWalker","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/dimtechstudio.com\/#\/schema\/person\/image\/","url":"http:\/\/dimtechstudio.com\/wp-content\/uploads\/2023\/11\/DimTechStudio-Icon-128x128-1.png","contentUrl":"http:\/\/dimtechstudio.com\/wp-content\/uploads\/2023\/11\/DimTechStudio-Icon-128x128-1.png","width":128,"height":128,"caption":"DimWalker"},"logo":{"@id":"http:\/\/dimtechstudio.com\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/dimtechstudio.com"],"url":"http:\/\/dimtechstudio.com\/index.php\/author\/walker\/"}]}},"_links":{"self":[{"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=36"}],"version-history":[{"count":1,"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":37,"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/posts\/36\/revisions\/37"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/media\/14"}],"wp:attachment":[{"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dimtechstudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}