<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stefano</title>
    <description>The latest articles on DEV Community by Stefano (@stefanodotit).</description>
    <link>https://dev.to/stefanodotit</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F841852%2Ffeae37d5-ae86-485e-aea0-5b0a46ff998f.jpeg</url>
      <title>DEV Community: Stefano</title>
      <link>https://dev.to/stefanodotit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stefanodotit"/>
    <language>en</language>
    <item>
      <title>Finally found a solution to clear the CDN cache using GitHub Actions!</title>
      <dc:creator>Stefano</dc:creator>
      <pubDate>Wed, 24 Jul 2024 13:21:18 +0000</pubDate>
      <link>https://dev.to/stefanodotit/finally-found-a-solution-to-clear-the-cdn-cache-using-github-actions-59fm</link>
      <guid>https://dev.to/stefanodotit/finally-found-a-solution-to-clear-the-cdn-cache-using-github-actions-59fm</guid>
      <description>&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;I've been struggling for a while to find a way to clear the CDN cache using GitHub Actions. I tried a few different methods, but none of them worked quite right. Finally, I found the solution!&lt;/p&gt;

&lt;p&gt;The solution is to use the &lt;strong&gt;Invalid CDN cache on GCP&lt;/strong&gt; action from the GitHub Marketplace. This action makes it easy to add CDN cache invalidation to your pipeline.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Before using this action, you must first use the &lt;code&gt;google-github-actions/auth&lt;/code&gt; action to authenticate to Google Cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  Required inputs:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;load-balancer-name&lt;/code&gt;: The name of the load balancer. This value can be found in the Google Cloud Console.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;path&lt;/code&gt;: The path to the content that you want to invalidate. This value must be a valid URL path. For example:

&lt;ul&gt;
&lt;li&gt;to invalidate the cache for the &lt;code&gt;/index.html&lt;/code&gt; file, you would set the &lt;code&gt;path&lt;/code&gt; input to &lt;code&gt;/index.html&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;to invalidate the whole directory, you would set the &lt;code&gt;path&lt;/code&gt; input to &lt;code&gt;/images/*&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;to invalidate everything, you would set the &lt;code&gt;path&lt;/code&gt; input to &lt;code&gt;/*&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Optional inputs:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;host&lt;/code&gt;: The hostname of the CDN endpoint. If you do not specify a hostname, the action will use the default hostname for the load balancer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gcloud_version&lt;/code&gt;: Version of the Cloud SDK to install. If unspecified or set to "latest", the latest available gcloud SDK version for the target platform will be installed. Example: "290.0.1".&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gcloud_component&lt;/code&gt;: Version of the Cloud SDK components to install and use.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example usage:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Invalidate Google Cloud CDN Cache&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt; &lt;span class="nv"&gt;main&lt;/span&gt; &lt;span class="pi"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;invalidate-cache&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
     &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Authenticate to Google Cloud&lt;/span&gt;
       &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;google-github-actions/auth@v2&lt;/span&gt;
       &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;

     &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Invalid CDN cache on GCP&lt;/span&gt;
       &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;stefanodotit/github-actions-invalidate-gcp-cdn@v1&lt;/span&gt;
       &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;load_balancer_name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;LOAD_BALANCER_NAME&lt;/span&gt;
          &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/path/to/invalid/*'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;I highly recommend this action to anyone who needs to clear their CDN cache using GitHub Actions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional notes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can find more information about the action on the GitHub Marketplace: &lt;a href="https://github.com/marketplace/actions/invalid-cdn-cache-on-gcp" rel="noopener noreferrer"&gt;https://github.com/marketplace/actions/invalid-cdn-cache-on-gcp&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You can also find more information about GCP's CDN API on the Google Cloud documentation website: &lt;a href="https://cloud.google.com/cdn" rel="noopener noreferrer"&gt;https://cloud.google.com/cdn&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this helps!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P.S.&lt;/strong&gt; If you have any other questions, please feel free to leave a comment below.&lt;/p&gt;

</description>
      <category>githubactions</category>
      <category>googlecloud</category>
      <category>gcp</category>
      <category>cache</category>
    </item>
    <item>
      <title>How to change a file locally without commit it on Git</title>
      <dc:creator>Stefano</dc:creator>
      <pubDate>Mon, 04 Apr 2022 14:12:16 +0000</pubDate>
      <link>https://dev.to/stefanodotit/how-to-change-a-file-locally-without-commit-it-on-git-2m1o</link>
      <guid>https://dev.to/stefanodotit/how-to-change-a-file-locally-without-commit-it-on-git-2m1o</guid>
      <description>&lt;h2&gt;
  
  
  Scenario
&lt;/h2&gt;

&lt;p&gt;I wanted to freeze a file in git, so that when someone commits, this file is not updated.&lt;br&gt;
The scenario was something like that: I need an ENV variable that usually will be available only on CI/CD to take the right token but on the local side I don't need it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;So I want a file that will be on my repository, and will be versioned but I want to change it on the local side and not commit it (I can skip it every time without include it on &lt;code&gt;git add&lt;/code&gt; but it's so boring and in long term will not work).&lt;br&gt;
I tried a different hack solution like &lt;code&gt;.gitignore&lt;/code&gt; but it did not work.&lt;br&gt;
So I read some documentation and I discovered the &lt;a href="https://git-scm.com/docs/git-update-index"&gt;&lt;code&gt;update-index&lt;/code&gt;&lt;/a&gt; option on git.&lt;/p&gt;

&lt;h2&gt;
  
  
  How update-index works
&lt;/h2&gt;

&lt;p&gt;With this command:&lt;br&gt;
&lt;code&gt;git update-index --assume-unchanged &amp;lt;file&amp;gt;&lt;/code&gt;&lt;br&gt;
Are you basically changing the &lt;a href="https://git-scm.com/docs/git-update-index#_using_assume_unchanged_bit"&gt;&lt;code&gt;assume unchanged bit&lt;/code&gt;&lt;/a&gt; and are you forcing Git to pretend it never changes. &lt;br&gt;
In this way Git will exclude this file from any tracking, so you can modify it on the local side and basically forget it. &lt;/p&gt;

&lt;p&gt;If you want to came back to the "normal version" u can easily exec this command:&lt;br&gt;
&lt;code&gt;git update-index --no-assume-unchanged &amp;lt;file&amp;gt;&lt;/code&gt; &lt;br&gt;
and everything will come back like before.&lt;/p&gt;

&lt;p&gt;If u want to check what kind of files are with this active flag you can easily run:&lt;br&gt;
&lt;code&gt;git ls-files -v&lt;/code&gt;&lt;br&gt;
Files where the flag is &lt;code&gt;--assume-changed&lt;/code&gt; have &lt;code&gt;H&lt;/code&gt;, &lt;code&gt;--assume-unchanged&lt;/code&gt; is &lt;code&gt;h&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>git</category>
      <category>programming</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
