{"id":559,"date":"2021-09-07T17:17:29","date_gmt":"2021-09-07T09:17:29","guid":{"rendered":"http:\/\/zhuxinyong.com\/?p=559"},"modified":"2021-09-07T19:55:22","modified_gmt":"2021-09-07T11:55:22","slug":"vuepress%e5%92%8cgithub-action-%e4%bd%bf%e7%94%a8%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/zhuxinyong.com\/?p=559","title":{"rendered":"VuePress\u548cGitHub Action \u4f7f\u7528\u65b9\u6cd5"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">VuePress<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/helpdev.eu\/wp-content\/uploads\/2018\/11\/Vuepress.jpg\" alt=\"Vuepress: A static page generator based on Vue.js \u2013 HelpDev\" width=\"499\" height=\"399\"\/><\/figure><\/div>\n\n\n\n<p>VuePress \u662f\u4e00\u4e2a Vue \u751f\u6001\u7684 SSG \uff0c\u4e3a Vue \u53ca\u5176\u5b50\u9879\u76ee\u6587\u6863\u800c\u751f\uff0c\u4e3b\u8981\u4ee5\u5185\u5bb9\u4e3a\u4e3b\u3002\u867d Nuxt \u53ef\u4ee5\u5b8c\u6210 VuePress \u7684\u529f\u80fd\uff0c\u4f46\u662f\u5b83\u7684\u76ee\u7684\u662f\u4e3a\u5e94\u7528\u800c\u751f\u3002\u66f4\u591a\u8bf7\u770b\u5b98\u65b9\u6587\u6863\uff1a<a href=\"https:\/\/vuepress.vuejs.org\/guide\/#introduction\" target=\"_blank\" rel=\"noopener\">https:\/\/vuepress.vuejs.org\/guide<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GitHub Action<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/915\/1*8Agtv-SaM-zw_GLzPI7p5w.png\" alt=\"GitHub Actions for beginners, CI\/CD - How - Why - What | Better Programming\" width=\"570\" height=\"290\"\/><\/figure><\/div>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Automate, customize, and execute your software development workflows right in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you&#8217;d like, including CI\/CD, and combine actions in a completely customized workflow.<\/p><cite><a href=\"https:\/\/docs.github.com\/en\/actions\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/docs.github.com\/en\/actions<\/a><\/cite><\/blockquote>\n\n\n\n<p>\u5b98\u65b9\u7ffb\u8bd1\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5728 GitHub Actions \u7684\u4ed3\u5e93\u4e2d\u81ea\u52a8\u5316\u3001\u81ea\u5b9a\u4e49\u548c\u6267\u884c\u8f6f\u4ef6\u5f00\u53d1\u5de5\u4f5c\u6d41\u7a0b\u3002 \u60a8\u53ef\u4ee5\u53d1\u73b0\u3001\u521b\u5efa\u548c\u5171\u4eab\u64cd\u4f5c\u4ee5\u6267\u884c\u60a8\u559c\u6b22\u7684\u4efb\u4f55\u4f5c\u4e1a\uff08\u5305\u62ec CI\/CD\uff09\uff0c\u5e76\u5c06\u64cd\u4f5c\u5408\u5e76\u5230\u5b8c\u5168\u81ea\u5b9a\u4e49\u7684\u5de5\u4f5c\u6d41\u7a0b\u4e2d\u3002<\/p><\/blockquote>\n\n\n\n<p>\u4e2a\u4eba\u7406\u89e3\u5c31\u662f\u81ea\u52a8\u5316\u4e00\u4e9b\u4efb\u52a1\uff0c\u5feb\u901f\u5c1d\u8bd5\u4e00\u4e0b\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/docs.github.com\/en\/actions\/quickstart\" target=\"_blank\">https:\/\/docs.github.com\/en\/actions\/quickstart<\/a><\/p>\n\n\n\n<p>GitHub Action \u662f\u8981\u4f9d\u8d56\u4e00\u4e2a .yml workflow \u7684\u914d\u7f6e\u6587\u4ef6\u6765\u8fd0\u884c\u7684\uff0c\u770b\u4e0b\u6211\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># name \u53ef\u4ee5\u81ea\u5b9a\u4e49\nname: Deploy GitHub Pages\n\n# \u89e6\u53d1\u6761\u4ef6\uff1a\u5728 push \u5230 main\/master \u5206\u652f\u540e\uff0c\u65b0\u7684 Github \u9879\u76ee \u5e94\u8be5\u90fd\u662f main\uff0c\u800c\u4e4b\u524d\u7684\u9879\u76ee\u4e00\u822c\u90fd\u662f master\non:\n  push:\n    branches:\n      - main\n\n# \u4efb\u52a1\njobs:\n  build-and-deploy:\n    # \u670d\u52a1\u5668\u73af\u5883\uff1a\u6700\u65b0\u7248 Ubuntu\n    runs-on: ubuntu-latest\n    steps:\n      # \u62c9\u53d6\u4ee3\u7801\n      - name: Checkout\n        uses: actions\/checkout@v2\n        with:\n          persist-credentials: false\n\n      # \u751f\u6210\u9759\u6001\u6587\u4ef6\n      - name: Build\n        run: npm install &amp;&amp; npm run docs:build\n\n      # \u90e8\u7f72\u5230 GitHub Pages\n      - name: Deploy\n        uses: JamesIves\/github-pages-deploy-action@4.1.5\n        with:\n          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} # \u4e5f\u5c31\u662f\u6211\u4eec\u521a\u624d\u751f\u6210\u7684 secret\n          BRANCH: gh-pages # \u90e8\u7f72\u5230 gh-pages \u5206\u652f\uff0c\u56e0\u4e3a main \u5206\u652f\u5b58\u653e\u7684\u4e00\u822c\u662f\u6e90\u7801\uff0c\u800c gh-pages \u5206\u652f\u5219\u7528\u6765\u5b58\u653e\u751f\u6210\u7684\u9759\u6001\u6587\u4ef6\n          FOLDER: docs\/.vuepress\/dist # vuepress \u751f\u6210\u7684\u9759\u6001\u6587\u4ef6\u5b58\u653e\u7684\u5730\u65b9<\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u51fa\u4e00\u4e2a workflow \u7531 name\u3001on \u3001jobs \u7b49\u7ec4\u6210<\/p>\n\n\n\n<p>name \u5c31\u662f\u7ed9 workflow \u53d6\u4e00\u4e2a\u540d\u5b57\uff0con \u5c31\u662f\u76d1\u542c\u67d0\u4e2a\u4e8b\u4ef6\u7136\u540e\u505a\u540e\u9762\u7684 jobs\uff0cjobs \u91cc\u9762\u662f\u5206 steps \u7684\u5c31\u662f\u4e00\u6b65\u6b65\u7684\u505a\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>GitHub Action \u7684\u5e02\u573a\u4e5f\u6709\u4e00\u4e2a VuePress \u7684 Action \u53ef\u4ee5\u53c2\u8003\u4e0b\uff1a<a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/marketplace\/actions\/deploy-to-github-pages\" target=\"_blank\">https:\/\/github.com\/marketplace\/actions\/deploy-to-github-pages<\/a><\/p>\n\n\n\n<p>\u6ce8\u610f\u70b9\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u8bbe\u7f6e access token <\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"763\" height=\"288\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image.png\" alt=\"\" class=\"wp-image-561\" srcset=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image.png 763w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-300x113.png 300w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-670x253.png 670w\" sizes=\"auto, (max-width: 763px) 100vw, 763px\" \/><\/figure>\n\n\n\n<p>GitHub \u53d6\u6d88\u4e86\u7528\u6237\u540d\/\u5bc6\u7801\u6388\u6743\uff0c\u6539\u7528 token \u7684\u65b9\u5f0f\uff0c\u751f\u6210\u7684\u5730\u65b9\u5728\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"387\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-1-1024x387.png\" alt=\"\" class=\"wp-image-562\" srcset=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-1-1024x387.png 1024w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-1-300x113.png 300w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-1-768x290.png 768w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-1-670x253.png 670w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-1.png 1464w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>\u8bb0\u4f4f\u751f\u6210\u7684 token \uff0c\u5237\u65b0\u9875\u9762\u540e\u5c31\u770b\u4e0d\u5230\u4e86\uff0c\u6240\u4ee5\u8bb0\u5f97\u4fdd\u5b58\u3002<\/figcaption><\/figure>\n\n\n\n<p>Action \u914d\u7f6e token  \u7684\u5730\u65b9\u5728\u9879\u76ee\u91cc\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"469\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-3-1024x469.png\" alt=\"\" class=\"wp-image-564\" srcset=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-3-1024x469.png 1024w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-3-300x137.png 300w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-3-768x352.png 768w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-3-1536x704.png 1536w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-3-670x307.png 670w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-3.png 1739w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>value \u5c31\u662f \u521a\u624d\u751f\u6210\u7684 token<\/figcaption><\/figure>\n\n\n\n<p>\u8fd9\u6837\u5c31\u914d\u7f6e\u597d\u4e86\uff0c\u7136\u540e\u672c\u5730\u5c31\u53ef\u4ee5 push  \u4ee3\u7801\uff0c\u5728 GitHub \u4e0a\u67e5\u770b Action:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"510\" src=\"http:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-4-1024x510.png\" alt=\"\" class=\"wp-image-565\" srcset=\"https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-4-1024x510.png 1024w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-4-300x149.png 300w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-4-768x383.png 768w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-4-1536x765.png 1536w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-4-670x334.png 670w, https:\/\/zhuxinyong.com\/wp-content\/uploads\/2021\/09\/image-4.png 1590w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u4e0b\u7bc7\u518d\u8bb2\u4e00\u4e0b\uff0c\u90e8\u7f72\u9047\u5230\u7684\u4e00\u4e9b\u5c0f\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VuePress VuePress \u662f\u4e00\u4e2a Vue \u751f\u6001\u7684 SSG \uff0c\u4e3a Vue \u53ca\u5176\u5b50\u9879\u76ee\u6587\u6863\u800c\u751f&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":569,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,20,27,3],"tags":[],"class_list":["post-559","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-all","category-frontend","category-tool","category-tech"],"_links":{"self":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/559","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=559"}],"version-history":[{"count":6,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/559\/revisions"}],"predecessor-version":[{"id":572,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/posts\/559\/revisions\/572"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=\/wp\/v2\/media\/569"}],"wp:attachment":[{"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuxinyong.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}