<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alejandro Orta on Medium]]></title>
        <description><![CDATA[Stories by Alejandro Orta on Medium]]></description>
        <link>https://medium.com/@orta.sanz.93?source=rss-582c59a31b38------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*zZ3nVHIKnRB88pcRQAUb0w.jpeg</url>
            <title>Stories by Alejandro Orta on Medium</title>
            <link>https://medium.com/@orta.sanz.93?source=rss-582c59a31b38------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 19:23:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@orta.sanz.93/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating Contentful backups with Semantic Release]]></title>
            <link>https://medium.com/packlinktech/creating-contentful-backups-with-semantic-release-863bfdf71b09?source=rss-582c59a31b38------2</link>
            <guid isPermaLink="false">https://medium.com/p/863bfdf71b09</guid>
            <category><![CDATA[contentful]]></category>
            <category><![CDATA[semantic-release]]></category>
            <category><![CDATA[javscript]]></category>
            <category><![CDATA[ci]]></category>
            <dc:creator><![CDATA[Alejandro Orta]]></dc:creator>
            <pubDate>Wed, 20 May 2020 07:17:28 GMT</pubDate>
            <atom:updated>2020-05-25T08:13:48.563Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Ws_sliHTu0oY-DcBDbWJg.jpeg" /><figcaption><em>Photo by </em><a href="https://unsplash.com/@steve_j?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>Steve Johnson</em></a><em> on </em><a href="https://unsplash.com/s/photos/medium?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><em>Unsplash</em></a></figcaption></figure><h3>About Contentful and Semantic Release</h3><p>You may have heard about <a href="https://www.contentful.com/"><strong>Contentful</strong></a> or <a href="https://semantic-release.gitbook.io/semantic-release/"><strong>Semantic Release</strong></a>. The first one it’s a CMS focused on API first and the second it’s a fully automated version management and package publishing tool with a lot of personalization capabilities. You might wonder what relationship can have between those, in this article I will explain how we are creating and saving backups of <strong>Contentful</strong> in <strong>Github</strong> using <strong>Semantic Release</strong> in a fully automatic workflow with <strong>CircleCI</strong>, in Packlink.</p><blockquote>This solution can work perfectly if you are using only one production environment in <strong>Contentful</strong>.<strong> </strong>You can use this approach and give it a spin (or two) to adjust it to your needs :)</blockquote><h3>Contentful CLI tools</h3><p>Contentful created a <a href="https://www.contentful.com/developers/docs/tutorials/cli/import-and-export/">nice set of tools</a> for exporting and importing content and models. You can use it as a CLI or separately. For this example we will use <a href="https://github.com/contentful/contentful-export">contentful-export tool</a> it’s already inside Contentful CLI but we want to use it alone for exporting a JSON for our space content, models and assets.</p><h4>List of things we need to start</h4><p>We will need two variables, the <strong>Contentful space ID</strong> and a <strong>management token</strong>. First let’s get the space id, head to <strong>space general settings </strong>and you will see it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VPhwKCUIjiiKZf83" /></figure><p>No matter if you want to create a backup of one environment or another, that ID it’s unique. Also, we are going to need a <strong>management token, </strong>for this example, we will use a <strong>personal access token</strong> head to APIs menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RaHBPKVhMzfSF1GL" /></figure><p><strong>Generate a new personal token</strong> and save it for later.</p><h4>Node script</h4><p>Let’s create an isolated node script with the necessary stuff for exporting all <strong>content</strong>, <strong>models</strong> and <strong>assets </strong>from the master environment, later we will put this script in our <strong>Semantic Release</strong> config.</p><p>First install the library:</p><pre>npm install --save-dev contentful-export</pre><p>Now create the script:</p><pre>// script.js</pre><pre>const contentfulExport = require(‘contentful-export’);</pre><pre>contentfulExport({</pre><pre>    spaceId: space-id’,</pre><pre>    managementToken: ‘token’,</pre><pre>    environmentId: ‘master’,</pre><pre>    exportDir: ‘backups’,</pre><pre>    contentFile: ‘environment-backup.json’,</pre><pre>    errorLogFile: ‘error.json’</pre><pre>});</pre><p><em>As you can see we are setting an </em><strong><em>exportDir</em></strong><em> if you do it make sure the folder exists before executing the script.</em></p><p>And run using <strong>node script.js </strong>if everything works as expected you will see this output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/0*zo_74FJc0djxGBvF" /></figure><p>Take a look to all <a href="https://github.com/contentful/contentful-export#gear-configuration-options">contentful-export configuration options</a>, maybe you want to enable/disable some.</p><h3>Semantic Release</h3><p>At this point you sure heard about <a href="https://github.com/semantic-release/semantic-release">Semantic Release</a> or you are using it and want to create new custom flows. If you are the first kind I encourage you to read all semantic documentation about how it works, how to install and configure, etc. In this guide, I will jump directly in to create a new plugin and add it in our semantic flow.</p><blockquote>For our example we will save the generated backup in <strong>GitHub </strong>using <a href="https://github.com/semantic-release/git">@semantic-release/git plugin</a>.</blockquote><h4>How to create a new a new Plugin</h4><p><a href="https://github.com/semantic-release/semantic-release/blob/master/docs/usage/plugins.md">The official documentation</a> explains perfectly how a semantic release plugin works, how we can use the plugin in any <a href="https://github.com/semantic-release/semantic-release/blob/master/README.md#release-steps">release step</a> and <a href="https://github.com/semantic-release/semantic-release/blob/master/docs/usage/plugins.md#plugin-options-configuration">pass configuration to it</a>.</p><p>For our example we will rely on two steps, the first one <strong>verifyConditions</strong> will check that both environment variables are present (space id and management token) then we’ll use <strong>generateNotes </strong>to create and save the generated JSON (at this step the new changelog file it’s generated, so we can assume it’s the step where we create/update files before commit them to git)</p><p>I’ve moved the example code into a gists file:</p><p><a href="https://gist.github.com/orta-sanz/22870b3664daa933d32e425ece05f576">https://gist.github.com/orta-sanz/22870b3664daa933d32e425ece05f576</a></p><p>All steps will be executed, that’s why we created a <strong>verified</strong> variable, to avoid any errors with contentful-export if there aren’t the required variables.</p><h4>Add our new plugin to semantic’s flow</h4><p>First let’s install contentful-export plugin:</p><pre>npm install contentful-export --save-dev</pre><p>Let’s assume that you are using <strong>release.config.js</strong> file to set up all semantic’s config and plugins, create a new folder next to the config file, let’s call it <strong>plugins</strong> and inside put the plugin’s file we created before. Remember that all plugins follow the same <a href="https://github.com/semantic-release/semantic-release/blob/master/docs/usage/plugins.md#plugins-declaration-and-execution-order">execution order</a> so we need to run our new plugin <strong>before</strong> semantic git.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*pZULlFsoX8m6KFiB" /></figure><p>As you can see we’ve also updated <strong>@semantic-release/git</strong> config to include all JSON files generated by our new plugin.</p><p>And that’s it, we have created our custom Contentful backup plugin for Semantic Release :)</p><p>As I said at the beginning of this guide this approach may not suit you perfectly but you can use it as an example of what can be achieved with Semantic Release and Contentful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=863bfdf71b09" width="1" height="1" alt=""><hr><p><a href="https://medium.com/packlinktech/creating-contentful-backups-with-semantic-release-863bfdf71b09">Creating Contentful backups with Semantic Release</a> was originally published in <a href="https://medium.com/packlinktech">Packlink Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>