{"componentChunkName":"component---src-templates-post-template-js","path":"/note-githubactions-for-pages-en","result":{"data":{"markdownRemark":{"id":"a40a364d-a501-5272-8fc3-9776cfe51544","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/note-githubactions-for-pages\">original page</a>.</p>\n</blockquote>\n<p>In this article, I summarize how to manage files other than published articles in a private repository for this blog, which I run with Gatsby and GitHub Pages.</p>\n<p>With a GitHub Pro-or-higher subscription, you can publish only a specific branch from a private repository with GitHub Pages. However, I wanted even Free users to be able to manage files other than published articles in a private repository by using GitHub Actions, so I used the procedure in this article.</p>\n<!-- omit in toc -->\n<h2 id=\"table-of-contents\" style=\"position:relative;\"><a href=\"#table-of-contents\" aria-label=\"table of contents permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Table of Contents</h2>\n<ul>\n<li><a href=\"#prerequisites\">Prerequisites</a></li>\n<li>\n<p><a href=\"#set-up-automatic-gatsby-deployment\">Set Up Automatic Gatsby Deployment</a></p>\n<ul>\n<li><a href=\"#about-the-github-action-for-automatic-deployment\">About the GitHub Action for Automatic Deployment</a></li>\n</ul>\n</li>\n<li>\n<p><a href=\"#push-files-to-another-repository-with-github-actions\">Push Files to Another Repository with GitHub Actions</a></p>\n<ul>\n<li><a href=\"#register-the-private-key-in-the-repository-that-runs-github-actions-source-repository\">Register the Private Key in the Repository That Runs GitHub Actions (Source Repository)</a></li>\n<li><a href=\"#register-the-public-key-in-the-destination-repository\">Register the Public Key in the Destination Repository</a></li>\n<li><a href=\"#push-files-to-another-repository-with-github-actions-1\">Push Files to Another Repository with GitHub Actions</a></li>\n</ul>\n</li>\n<li><a href=\"#summary\">Summary</a></li>\n</ul>\n<h2 id=\"prerequisites\" style=\"position:relative;\"><a href=\"#prerequisites\" aria-label=\"prerequisites permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Prerequisites</h2>\n<p>To follow this procedure, you need to prepare the following in advance.</p>\n<ul>\n<li><strong>A GitHub account on the Free plan</strong></li>\n<li><strong>A private repository to manage the files for the published pages and GitHub Actions</strong></li>\n<li><strong>A public repository that contains only the published articles generated by a static site generator and is published with GitHub Pages</strong></li>\n</ul>\n<p>This article does not cover how to use the static site generator or how to configure GitHub Pages.</p>\n<p>For how to use Gatsby locally and publish deployed articles on GitHub Pages, please see the following.</p>\n<p>Reference: <a href=\"/note-how-to-deploy-gatsby-spa-en\">Notes on Setting Up an Environment to Publish a Gatsby SPA Blog on GitHub Pages - Kaeru no Himitsukichi</a></p>\n<h2 id=\"set-up-automatic-gatsby-deployment\" style=\"position:relative;\"><a href=\"#set-up-automatic-gatsby-deployment\" aria-label=\"set up automatic gatsby deployment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Set Up Automatic Gatsby Deployment</h2>\n<p>First, add the following GitHub Actions workflow to the private repository that manages Gatsby and the Markdown files.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> deploy<span class=\"token punctuation\">-</span>and<span class=\"token punctuation\">-</span>push\n<span class=\"token key atrule\">on</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">push</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">branches</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> main\n<span class=\"token key atrule\">jobs</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">deploy-and-push</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">runs-on</span><span class=\"token punctuation\">:</span> ubuntu<span class=\"token punctuation\">-</span>latest\n    <span class=\"token key atrule\">container</span><span class=\"token punctuation\">:</span> kashiwabayuki/gatsby<span class=\"token punctuation\">-</span>env\n\n    <span class=\"token key atrule\">steps</span><span class=\"token punctuation\">:</span>\n    <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> actions/checkout@v2\n      <span class=\"token key atrule\">with</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">submodules</span><span class=\"token punctuation\">:</span> <span class=\"token boolean important\">true</span>\n\n    <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Install npm\n      <span class=\"token key atrule\">env</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">NODE_OPTIONS</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"--max_old_space_size=4096\"</span>\n      <span class=\"token key atrule\">run</span><span class=\"token punctuation\">:</span> npm install\n\n    <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Deploy\n      <span class=\"token key atrule\">run</span><span class=\"token punctuation\">:</span> gatsby clean <span class=\"token important\">&amp;&amp;</span> gatsby build <span class=\"token punctuation\">-</span><span class=\"token punctuation\">-</span>prefix<span class=\"token punctuation\">-</span>paths <span class=\"token important\">&amp;&amp;</span> echo 'kashiwaba<span class=\"token punctuation\">-</span>yuki.com' <span class=\"token punctuation\">></span> public/CNAME\n\n    <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Pushes to public repository\n      <span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> cpina/github<span class=\"token punctuation\">-</span>action<span class=\"token punctuation\">-</span>push<span class=\"token punctuation\">-</span>to<span class=\"token punctuation\">-</span>another<span class=\"token punctuation\">-</span>repository@main\n      <span class=\"token key atrule\">env</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">SSH_DEPLOY_KEY</span><span class=\"token punctuation\">:</span> $<span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> secrets.SSH_DEPLOY_KEY <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span>\n      <span class=\"token key atrule\">with</span><span class=\"token punctuation\">:</span>\n        <span class=\"token key atrule\">source-directory</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'./public'</span>\n        <span class=\"token key atrule\">destination-github-username</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'kash1064'</span>\n        <span class=\"token key atrule\">destination-repository-name</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'Kaeru-no-Himitsukichi-Public'</span>\n        <span class=\"token key atrule\">user-email</span><span class=\"token punctuation\">:</span> kashiwabayuki@gmail.com\n        <span class=\"token key atrule\">target-branch</span><span class=\"token punctuation\">:</span> public</code></pre></div>\n<h3 id=\"about-the-github-action-for-automatic-deployment\" style=\"position:relative;\"><a href=\"#about-the-github-action-for-automatic-deployment\" aria-label=\"about the github action for automatic deployment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>About the GitHub Action for Automatic Deployment</h3>\n<p>Let’s look at it from top to bottom.</p>\n<p>First, the following section defines the action name and when it runs.</p>\n<p>This time, I set it to run when a push is made to the <code class=\"language-text\">main</code> branch.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> deploy<span class=\"token punctuation\">-</span>and<span class=\"token punctuation\">-</span>push\n<span class=\"token key atrule\">on</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">push</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">branches</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> main</code></pre></div>\n<p>Next, inside the job it uses the <code class=\"language-text\">ubuntu-latest</code> workflow and prepares a custom deployment container called <code class=\"language-text\">kashiwabayuki/gatsby-env</code>.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">deploy-and-push</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">runs-on</span><span class=\"token punctuation\">:</span> ubuntu<span class=\"token punctuation\">-</span>latest\n  <span class=\"token key atrule\">container</span><span class=\"token punctuation\">:</span> kashiwabayuki/gatsby<span class=\"token punctuation\">-</span>env</code></pre></div>\n<p>This container image was created using the procedure in the following article.</p>\n<p>Reference: <a href=\"/note-how-to-deploy-gatsby-spa-en#create-a-container-for-gatsby-development\">Notes on Setting Up an Environment to Publish a Gatsby SPA Blog on GitHub Pages - Kaeru no Himitsukichi</a></p>\n<p>Then, using <code class=\"language-text\">actions/checkout@v2</code>, it clones the files from the <code class=\"language-text\">main</code> branch of the private repository into the container, installs the dependent node modules, and finally builds the articles with the Gatsby command.</p>\n<p>Incidentally, it takes about 10 minutes in total to finish <code class=\"language-text\">npm install</code> and <code class=\"language-text\">gatsby build</code>. It is wasteful in terms of resources, and private repositories also have a 2000 minutes/month execution time limit, so I would like to shorten it, but I could not come up with a good idea.</p>\n<p>This Action only runs when publishing an article, and there is no way it will exceed 2000 minutes, so I am leaving it on hold for now.</p>\n<p>I plan to revisit it if I think of something later.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">steps</span><span class=\"token punctuation\">:</span>\n<span class=\"token punctuation\">-</span> <span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> actions/checkout@v2\n  <span class=\"token key atrule\">with</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">submodules</span><span class=\"token punctuation\">:</span> <span class=\"token boolean important\">true</span>\n\n<span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Install npm\n  <span class=\"token key atrule\">env</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">NODE_OPTIONS</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"--max_old_space_size=4096\"</span>\n  <span class=\"token key atrule\">run</span><span class=\"token punctuation\">:</span> npm install\n\n<span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Deploy\n  <span class=\"token key atrule\">run</span><span class=\"token punctuation\">:</span> gatsby clean <span class=\"token important\">&amp;&amp;</span> gatsby build <span class=\"token punctuation\">-</span><span class=\"token punctuation\">-</span>prefix<span class=\"token punctuation\">-</span>paths <span class=\"token important\">&amp;&amp;</span> echo 'kashiwaba<span class=\"token punctuation\">-</span>yuki.com' <span class=\"token punctuation\">></span> public/CNAME</code></pre></div>\n<p>At this point, the files for publishing have been built in the <code class=\"language-text\">./public</code> directory inside the container, so push the generated files to the public repository.</p>\n<h2 id=\"push-files-to-another-repository-with-github-actions\" style=\"position:relative;\"><a href=\"#push-files-to-another-repository-with-github-actions\" aria-label=\"push files to another repository with github actions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Push Files to Another Repository with GitHub Actions</h2>\n<p>When you push files to another repository with GitHub Actions, you need to set a deploy key with write access for the destination repository.</p>\n<p>To register this key, generate a public/private key pair in advance with the <code class=\"language-text\">ssh-keygen</code> command.</p>\n<h3 id=\"register-the-private-key-in-the-repository-that-runs-github-actions-source-repository\" style=\"position:relative;\"><a href=\"#register-the-private-key-in-the-repository-that-runs-github-actions-source-repository\" aria-label=\"register the private key in the repository that runs github actions source repository permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Register the Private Key in the Repository That Runs GitHub Actions (Source Repository)</h3>\n<p>First, register the private key in the repository that runs GitHub Actions.</p>\n<p>From [Secrets] > [Actions] in [Settings] on the GitHub repository page, you can register a new Secret.</p>\n<p>At this time, set the Secret name to <code class=\"language-text\">SSH_DEPLOY_KEY</code>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 868px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b9ddef0c27ce6c83ecdca474681a86f6/748b0/image-20221029005654913.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 34.583333333333336%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsTAAALEwEAmpwYAAAA/0lEQVQoz5WR226CQBCG97YplIPL2QVBhXJQEBWNafr+b/V3dtSENL2oF192Zth8/AzCTmossgEL1cJNewRphaJskRafjGH7MJ3g34iQBG60hikVrCCH7S0hwxRelPH5ioyFSbZFmpeIVAFHRjApkTHjww0Z83HO+98yPRcxCf14xY0WvFse82qy5wuEpE9TeYXlqoQqatpbTfUWjp/AkjFj/4WX3JM+kukQG9q9yDYNxss3duMVh+kL/enGdMMF7TDxvDtQ3Z9pNnGtnxVlx7LnT3szJZpugNCJGrpc708saPZn6ifqj6i6kWZ3Qb078p2G0FKd0pitRifM1xV+AGNGt4bpE9F9AAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/b9ddef0c27ce6c83ecdca474681a86f6/8ac56/image-20221029005654913.webp 240w,\n/static/b9ddef0c27ce6c83ecdca474681a86f6/d3be9/image-20221029005654913.webp 480w,\n/static/b9ddef0c27ce6c83ecdca474681a86f6/1ae05/image-20221029005654913.webp 868w\"\n              sizes=\"(max-width: 868px) 100vw, 868px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/b9ddef0c27ce6c83ecdca474681a86f6/8ff5a/image-20221029005654913.png 240w,\n/static/b9ddef0c27ce6c83ecdca474681a86f6/e85cb/image-20221029005654913.png 480w,\n/static/b9ddef0c27ce6c83ecdca474681a86f6/748b0/image-20221029005654913.png 868w\"\n            sizes=\"(max-width: 868px) 100vw, 868px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/b9ddef0c27ce6c83ecdca474681a86f6/748b0/image-20221029005654913.png\"\n            alt=\"image-20221029005654913\"\n            title=\"image-20221029005654913\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p><code class=\"language-text\">SSH_DEPLOY_KEY</code> is used in the processing of <code class=\"language-text\">cpina/github-action-push-to-another-repository@main</code>, as shown below.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Pushes to public repository\n\t<span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> cpina/github<span class=\"token punctuation\">-</span>action<span class=\"token punctuation\">-</span>push<span class=\"token punctuation\">-</span>to<span class=\"token punctuation\">-</span>another<span class=\"token punctuation\">-</span>repository@main\n    <span class=\"token key atrule\">env</span><span class=\"token punctuation\">:</span>\n    \t<span class=\"token key atrule\">SSH_DEPLOY_KEY</span><span class=\"token punctuation\">:</span> $<span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> secrets.SSH_DEPLOY_KEY <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span></code></pre></div>\n<h3 id=\"register-the-public-key-in-the-destination-repository\" style=\"position:relative;\"><a href=\"#register-the-public-key-in-the-destination-repository\" aria-label=\"register the public key in the destination repository permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Register the Public Key in the Destination Repository</h3>\n<p>Next, register the public key as a Deploy key from [Settings] in the repository used for publishing.</p>\n<p>You can choose any name you like for the Title, but you need to enable [Allow write access].</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 876px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/48ae31ac4099608173b38e533e84898e/1b1d5/image-20221029010004464.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 60.416666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAABY0lEQVQoz62SW07DMBBFXeI4cdo0zdN5p2mr0iIkBDtgG2yFxV/GzoMIiZYPPo7ujG3ZdzzDou4FSf+GmFR1V+xPV/TnZ8SqwTpI4YcKm10GX0PxPVhcHhFknSHMWnNRnLcI4pIO5NhG3/zpQlXtEWcV3HUA293ClgPCC+CMDPHOONZub8GirEaYVibxtgnWxFK9Ra4dLB0b1yNTBSyh8rxtbNwJqd3sBldyZHSoY1PBVMWo0zmd64fJYYWmOyFKS6R5DVW2yOkb8rKjvIEqWrOmKE9UNezrvaIZ18c9ukduQjDherBtTggI4cAWYo65bc+x0OsjYqETnHM40gezuABj7F/QjWUr7lJiEZwSG+xB3Maa1MGKyxlmuXA3EY1NfaZ/6qGqHrrjpqM0Hr/h+fGM/KFmbIrDGd3lCfXhEUVzRFLQB1PnJ02NDrEe+ruDffh4xdvnO4ILdUnSK2F2d3hv8QWFwBotlcb8dQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/48ae31ac4099608173b38e533e84898e/8ac56/image-20221029010004464.webp 240w,\n/static/48ae31ac4099608173b38e533e84898e/d3be9/image-20221029010004464.webp 480w,\n/static/48ae31ac4099608173b38e533e84898e/21dbd/image-20221029010004464.webp 876w\"\n              sizes=\"(max-width: 876px) 100vw, 876px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/48ae31ac4099608173b38e533e84898e/8ff5a/image-20221029010004464.png 240w,\n/static/48ae31ac4099608173b38e533e84898e/e85cb/image-20221029010004464.png 480w,\n/static/48ae31ac4099608173b38e533e84898e/1b1d5/image-20221029010004464.png 876w\"\n            sizes=\"(max-width: 876px) 100vw, 876px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/48ae31ac4099608173b38e533e84898e/1b1d5/image-20221029010004464.png\"\n            alt=\"image-20221029010004464\"\n            title=\"image-20221029010004464\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Now the private key and public key pair have been registered in the source repository and the publishing repository.</p>\n<h3 id=\"push-files-to-another-repository-with-github-actions-1\" style=\"position:relative;\"><a href=\"#push-files-to-another-repository-with-github-actions-1\" aria-label=\"push files to another repository with github actions 1 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Push Files to Another Repository with GitHub Actions</h3>\n<p>Now that everything is ready, push the deployed Gatsby files to the public repository.</p>\n<p>I could have written the process myself, but this time I decided to use <a href=\"https://github.com/cpina/github-action-push-to-another-repository\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">cpina/github-action-push-to-another-repository</a>.</p>\n<p>I added the following step at the end of the steps.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Pushes to public repository\n  <span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> cpina/github<span class=\"token punctuation\">-</span>action<span class=\"token punctuation\">-</span>push<span class=\"token punctuation\">-</span>to<span class=\"token punctuation\">-</span>another<span class=\"token punctuation\">-</span>repository@main\n  <span class=\"token key atrule\">env</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">SSH_DEPLOY_KEY</span><span class=\"token punctuation\">:</span> $<span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> secrets.SSH_DEPLOY_KEY <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span>\n  <span class=\"token key atrule\">with</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">source-directory</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'./public'</span>\n    <span class=\"token key atrule\">destination-github-username</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'kash1064'</span>\n    <span class=\"token key atrule\">destination-repository-name</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'Kaeru-no-Himitsukichi-Public'</span>\n    <span class=\"token key atrule\">user-email</span><span class=\"token punctuation\">:</span> kashiwabayuki@gmail.com\n    <span class=\"token key atrule\">target-branch</span><span class=\"token punctuation\">:</span> public</code></pre></div>\n<p>As described in the following documentation, <code class=\"language-text\">cpina/github-action-push-to-another-repository</code> can use a private key stored in Secrets to push any directory inside the container to a specified repository.</p>\n<p>Reference: <a href=\"https://cpina.github.io/push-to-another-repository-docs/overview.html\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Overview — github-action-push-to-another-repository documentation</a></p>\n<p>This time it is configured to push the <code class=\"language-text\">./public</code> directory, where Gatsby places the deployed files, to the <code class=\"language-text\">public</code> branch of the repository used for publishing.</p>\n<p>Once the Action finishes successfully, updates to the private repository trigger a build, the built articles are pushed to the publishing branch of the public repository, and the blog on GitHub Pages is updated.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>GitHub Actions are handy.</p>","fields":{"slug":"/note-githubactions-for-pages-en","tagSlugs":["/tag/notes/","/tag/github/","/tag/blog/","/tag/english/"]},"frontmatter":{"date":"2022-10-29","description":"How Free-plan users can manage files other than published articles in a private repository even while using GitHub Pages.","tags":["Notes","Github","Blog","English"],"title":"Even as a GitHub Free User, I Want to Manage Files Other Than Published Articles in a Private Repository!","socialImage":{"publicURL":"/static/dc4d8b7f8795f3c3d3489d9957d155f2/no-image.png"}}}},"pageContext":{"slug":"/note-githubactions-for-pages-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}