{"componentChunkName":"component---src-templates-blog-post-js","path":"/gitlab-ci/","result":{"data":{"site":{"siteMetadata":{"title":"Jeff Beeman's Blog"}},"markdownRemark":{"id":"c2486d4a-7a1e-56c6-b45a-7930836665d9","excerpt":"Rough notes below for now package.json Added a  line to facilitate build and deploy:  gitlab-ci.yml GitLab CI configuration Add Cloudflare-related environment…","html":"<h2>Rough notes below for now</h2>\n<h3>package.json</h3>\n<p>Added a <code class=\"language-text\">scripts</code> line to facilitate build and deploy: <code class=\"language-text\">&quot;publish&quot;: &quot;npm run build &amp;&amp; wrangler publish&quot;</code></p>\n<h3>gitlab-ci.yml</h3>\n<div class=\"gatsby-highlight\" data-language=\"yml\"><pre class=\"language-yml\"><code class=\"language-yml\"><span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> node<span class=\"token punctuation\">:</span>latest\n\n<span class=\"token key atrule\">cache</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">key</span><span class=\"token punctuation\">:</span> $<span class=\"token punctuation\">{</span>CI_COMMIT_REF_SLUG<span class=\"token punctuation\">}</span>\n  <span class=\"token key atrule\">paths</span><span class=\"token punctuation\">:</span>\n    <span class=\"token punctuation\">-</span> node_modules/\n    <span class=\"token punctuation\">-</span> .cache/\n    <span class=\"token punctuation\">-</span> public/\n\n<span class=\"token key atrule\">before_script</span><span class=\"token punctuation\">:</span>\n  <span class=\"token punctuation\">-</span> npm <span class=\"token punctuation\">-</span><span class=\"token punctuation\">-</span>version\n  <span class=\"token punctuation\">-</span> node <span class=\"token punctuation\">-</span><span class=\"token punctuation\">-</span>version\n  <span class=\"token punctuation\">-</span> npm install <span class=\"token punctuation\">-</span>g gatsby<span class=\"token punctuation\">-</span>cli\n  <span class=\"token punctuation\">-</span> npm install <span class=\"token punctuation\">-</span>g @cloudflare/wrangler\n\n<span class=\"token key atrule\">build</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">script</span><span class=\"token punctuation\">:</span>\n    <span class=\"token comment\"># Use `npm ci` because it's faster than `npm install` and designed for this context.</span>\n    <span class=\"token punctuation\">-</span> npm ci\n    <span class=\"token comment\"># Env vars are CF_ACCOUNT_ID, CF_API_TOKEN, CF_ZONE_ID and set in GitLab CI settings. </span>\n    <span class=\"token comment\"># Note that these variables must *not* be protected.</span>\n    <span class=\"token punctuation\">-</span> npm run publish\n  <span class=\"token key atrule\">only</span><span class=\"token punctuation\">:</span>\n    <span class=\"token punctuation\">-</span> main</code></pre></div>\n<h3>GitLab CI configuration</h3>\n<p>Add Cloudflare-related environment variables to GitLab CI/CD settings for the project, under “Variables”  Variables should <em>not</em> be protected, otherwise GitLab CI won’t see them properly (banged my head against this for a bit).</p>\n<p>The variables are self-explanatory as you setup with your Cloudflare tokens:</p>\n<ul>\n<li><code class=\"language-text\">CF_ACCOUNT_ID</code></li>\n<li><code class=\"language-text\">CF_API_TOKEN</code></li>\n<li><code class=\"language-text\">CF_ZONE_ID</code></li>\n</ul>\n<h3>References</h3>\n<ul>\n<li>[https://www.gatsbyjs.com/docs/deploying-to-gitlab-pages/]</li>\n<li>[https://blog.vence.tech/posts/ci-cd-pipeline-on-gitlab/]</li>\n</ul>","frontmatter":{"title":"Notes regarding Gatsby deployment to a Cloudflare Worker using GitLab CI","date":"April 17, 2021","description":"How I got a Gatsby to build in GitLab CI and deploy to a Cloudflare Worker."}},"previous":{"fields":{"slug":"/wsl-ubuntu/"},"frontmatter":{"title":"Notes regarding my local Drupal development environment on Ubuntu 20.04 LTS with WSL 2 on Windows"}},"next":null},"pageContext":{"id":"c2486d4a-7a1e-56c6-b45a-7930836665d9","previousPostId":"b043f627-8c8d-5ab9-a6d6-0d94811a6ab2","nextPostId":null}},"staticQueryHashes":["2841359383","3257411868"]}