<p>I have a github action that builds a docker image and pushes it to our repo.</p>
<pre><code>docker build -t mySuperCoolTag --build-arg PIP_INDEX_URL=${{ secrets.PIP_INDEX_URL }} .
docker push mySuperCoolTag
</code></pre>
<p>Per our deployment process, we take the SHA of the latest image, add it to our yaml files for K8s to read and use.</p>
<p>Originally, I incorrectly thought that the local SHA of the image was the same being pushed to the repo, and I grabbed it and added it to the file like so:</p>
<pre><code>      docker images --no-trunc --quiet mySuperCoolTag
      dockerSHA=$(docker images --no-trunc --quiet mySuperCoolTag)
      
      #replace the current SHA in the configuration with the latest SHA
      sed -i -E &quot;s/sha256:\w*/$dockerSHA/g&quot; config-file.yaml
</code></pre>
<p>This ended up not being the SHA I was looking for.  😅</p>
<p><code>docker push</code> <em>does</em> output the expected SHA, but I'm not too sure how to programmatically grab that SHA save having a script read the output and grabbing it from there, but I'm hoping there is a more succinct way to do it. Any idea?</p>

Another Stackoverflow User
<p>Ended up using this command instead:</p>
<pre><code>dockerSHA=$(docker inspect --format='{{index .RepoDigests 0}}' mySuperCoolTag  | perl -wnE'say /sha256.*/g')
</code></pre>
<p>And it just works.</p>
