<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>CI/CD on Jenny blog</title>
        <link>https://yue-jenny.github.io/categories/ci/cd/</link>
        <description>Recent content in CI/CD on Jenny blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en-us</language><atom:link href="https://yue-jenny.github.io/categories/ci/cd/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>在 Argo CD 中使用 Github App Credential 作為驗證方式</title>
        <link>https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/</link>
        <pubDate>Tue, 10 Jan 2023 16:05:56 +0800</pubDate>
        
        <guid>https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/</guid>
        <description>&lt;h2 id=&#34;在-argo-cd-中使用-github-app-credential-作為驗證方式&#34;&gt;在 Argo CD 中使用 Github App Credential 作為驗證方式&lt;/h2&gt;
&lt;h3 id=&#34;前言&#34;&gt;前言&lt;/h3&gt;
&lt;p&gt;在先前文章&lt;a class=&#34;link&#34; href=&#34;../%e4%bd%bf%e7%94%a8-docker-desktop-%e9%81%8b%e8%a1%8c-argo-cd-%e4%bb%a5%e5%8f%8a%e5%9c%a8-argo-cd-%e5%85%a7%e5%bb%ba%e7%ab%8b-app-%e5%81%b5%e6%b8%ac-repository-%e7%8b%80%e6%85%8b/&#34; &gt;使用 Docker Desktop 運行 Argo CD 以及在 Argo CD 內建立 App 偵測 repository 狀態&lt;/a&gt; 有提到 private repository 驗證的方式有 &lt;code&gt;SSH&lt;/code&gt;、&lt;code&gt;Https&lt;/code&gt; 以及 &lt;code&gt;Github App Credential&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;此文章來筆記下，如何在 Argo CD 中使用 &lt;code&gt;Github App Credential&lt;/code&gt; 作為驗證方式&lt;/p&gt;
&lt;h3 id=&#34;實作&#34;&gt;實作&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;建立 Github App&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;步驟可參考 👉 &lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;其中，特別需要設定的值&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Github App Name&lt;/strong&gt;: 為你的 Github App 取名稱&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Homepage URL&lt;/strong&gt;: 你的 web app URL&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;我的 argo cd 是以 docker desktop 啟動，並利用 port forward 方式，讓本地利用 &lt;a class=&#34;link&#34; href=&#34;http://localhost&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;localhost&lt;/a&gt; 可連線 dashboard，可參考&lt;a class=&#34;link&#34; href=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;我的文章使用 Docker Desktop 運行 Argo CD&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Callback URL&lt;/strong&gt;: 當 github 認證完畢後，要 redirect 回去的 URL&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/basic-info-1.png&#34;
	width=&#34;927&#34;
	height=&#34;866&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/basic-info-1_huc5491ce2dc66550e600cbcca3297735a_53484_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/basic-info-1_huc5491ce2dc66550e600cbcca3297735a_53484_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;basic information 1 &#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;107&#34;
		data-flex-basis=&#34;256px&#34;
	
&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/basic-info-2.png&#34;
	width=&#34;839&#34;
	height=&#34;911&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/basic-info-2_hua8d901ec71c1f4aeb1737fac5fac2f29_47817_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/basic-info-2_hua8d901ec71c1f4aeb1737fac5fac2f29_47817_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;basic information 2 &#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;92&#34;
		data-flex-basis=&#34;221px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;建立完成 Github App 後，還有兩件事情要做，Argo CD 設定連線時會用到&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;查看 Github App Installation ID&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;看 URL &lt;strong&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/settings/installations/%7bYour&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://github.com/settings/installations/{Your&lt;/a&gt; Github App Installation ID}&lt;/strong&gt;, 可確認 Github App Installation ID&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;建立 private key&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;到 &lt;code&gt;Settings / Developer settings / Github Apps / {your-github-app-name}&lt;/code&gt; 的 &lt;code&gt;General&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/get-private-key-1.png&#34;
	width=&#34;681&#34;
	height=&#34;337&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/get-private-key-1_hub4eca3abecd1bcd4a43190f529bfc084_23447_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/get-private-key-1_hub4eca3abecd1bcd4a43190f529bfc084_23447_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;set a private key&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;202&#34;
		data-flex-basis=&#34;484px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;將頁面往下拉可以看見 Private keys，點 &lt;code&gt;Generate a private key&lt;/code&gt; 建立一組 private key&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/get-private-key-2.png&#34;
	width=&#34;806&#34;
	height=&#34;251&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/get-private-key-2_hu418a32b8c70bb709a8142c5945f221c3_17725_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/get-private-key-2_hu418a32b8c70bb709a8142c5945f221c3_17725_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;set a private key&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;321&#34;
		data-flex-basis=&#34;770px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;到 Argo CD 的 Repositories 設定連線資訊&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;如何到這頁來設定，可參考&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/user-guide/private-repositories/#github-app-credential&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;這邊要填寫與設定的資訊分成兩部分&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;先選到 &lt;code&gt;VIA GITHUB APP&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;依照上面的訊息完成填寫&lt;code&gt;框 2&lt;/code&gt;的內容&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;點 &lt;code&gt;CONNECT&lt;/code&gt;，完成&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/connect-repo-1.png&#34;
	width=&#34;849&#34;
	height=&#34;881&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/connect-repo-1_hud66466c9c685aacdb265a07c8d099a51_42099_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/connect-repo-1_hud66466c9c685aacdb265a07c8d099a51_42099_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Repositories 設定連線資訊&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;96&#34;
		data-flex-basis=&#34;231px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;連線成功&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/connect-repo-2.png&#34;
	width=&#34;1377&#34;
	height=&#34;193&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/connect-repo-2_hu171eb20f762b1004e7638657a00c1e7d_21668_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/connect-repo-2_hu171eb20f762b1004e7638657a00c1e7d_21668_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;連結成功&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;713&#34;
		data-flex-basis=&#34;1712px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;建立一組 NEW APP&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/new-app.png&#34;
	width=&#34;1408&#34;
	height=&#34;564&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/new-app_hu8d10ffa92c0cef9f32058c6d59afce6b_119484_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E5%9C%A8-argo-cd-%E4%B8%AD%E4%BD%BF%E7%94%A8-github-app-credential-%E4%BD%9C%E7%82%BA%E9%A9%97%E8%AD%89%E6%96%B9%E5%BC%8F/new-app_hu8d10ffa92c0cef9f32058c6d59afce6b_119484_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;NEW APP&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;249&#34;
		data-flex-basis=&#34;599px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;心得&#34;&gt;心得&lt;/h2&gt;
&lt;p&gt;看到官方提供驗證 private repository 的方式有 &lt;code&gt;Github App Credential&lt;/code&gt;，讓我相當好奇，於是就有了這篇文章。&lt;br&gt;
後續再寫一篇文章來記錄 &lt;code&gt;Github App&lt;/code&gt; 與 &lt;code&gt;OAuth App&lt;/code&gt;差異。&lt;/p&gt;
&lt;h2 id=&#34;參考資料-&#34;&gt;參考資料 👐&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;about-apps&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/user-guide/private-repositories/#github-app-credential&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;github-app-credential&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;🍀 「記錄」是為了有意識地、有條理地統整所學的學習知識。&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;🍀 最後，若喜歡我的分享，可以免費幫我按讚，是對我最大的鼓勵! ✨ ✨ ✨&lt;/strong&gt;&lt;/p&gt;
</description>
        </item>
        <item>
        <title>Argo CD 是什麼?</title>
        <link>https://yue-jenny.github.io/2023/01/argo-cd-%E6%98%AF%E4%BB%80%E9%BA%BC/</link>
        <pubDate>Thu, 05 Jan 2023 10:56:11 +0800</pubDate>
        
        <guid>https://yue-jenny.github.io/2023/01/argo-cd-%E6%98%AF%E4%BB%80%E9%BA%BC/</guid>
        <description>&lt;h2 id=&#34;argo-cd-是什麼&#34;&gt;Argo CD 是什麼?&lt;/h2&gt;
&lt;p&gt;Argo CD是一個用於持續交付（Continuous Delivery）的工具，用於自動化應用程序的部署、更新和操作。&lt;br&gt;
它是基於Kubernetes的開源項目，旨在幫助團隊更有效地管理和交付應用程序。&lt;/p&gt;
&lt;p&gt;Argo CD允許開發人員和運維團隊使用 &lt;strong&gt;GitOps 模型&lt;/strong&gt;來管理基礎設施和應用程序的狀態。&lt;/p&gt;
&lt;p&gt;GitOps是一種軟體開發實踐，它&lt;strong&gt;將Git作為單一可信源&lt;/strong&gt;來管理應用程序的狀態和配置。&lt;/p&gt;
&lt;p&gt;透過將應用程序的狀態描述為Git存儲庫中的一組聲明，Argo CD可以根據這些聲明自動驅動應用程序的部署和更新。&lt;/p&gt;
&lt;h2 id=&#34;前言&#34;&gt;前言&lt;/h2&gt;
&lt;p&gt;這部分會分享 Argo CD 的&lt;code&gt;中心思想&lt;/code&gt;、&lt;code&gt;架構&lt;/code&gt;與&lt;code&gt;功能&lt;/code&gt;。&lt;/p&gt;
&lt;h3 id=&#34;中心思想-gitops-pattern&#34;&gt;中心思想 GitOps pattern&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Argo CD 遵循 GitOps 模式，即&lt;strong&gt;以 Git repositories 作為唯一識別 application 狀態的來源&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;argo-cd-作為-kubernetes-controller&#34;&gt;Argo CD 作為 kubernetes controller&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Argo CD 作為 kubernetes controller，持續偵測運行中的 application，並&lt;strong&gt;比較現在狀態與目標狀態&lt;/strong&gt;！&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;可用以下幾種方式建立 Argo CD 的 kubernetes manifest&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://kustomize.io/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;kustomize&lt;/a&gt; applications&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://helm.sh/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;helm&lt;/a&gt; charts&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://jsonnet.org/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;jsonnet&lt;/a&gt; files&lt;/li&gt;
&lt;li&gt;Plain directory of YAML/json manifests&lt;/li&gt;
&lt;li&gt;Any custom config management tool configured as a config management plugin&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;argo-cd-architecture&#34;&gt;Argo CD architecture&lt;/h3&gt;
&lt;h4 id=&#34;架構圖&#34;&gt;架構圖&lt;/h4&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/argo-cd-%E6%98%AF%E4%BB%80%E9%BA%BC/argocd_architecture.webp&#34;
	width=&#34;743&#34;
	height=&#34;708&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/argo-cd-%E6%98%AF%E4%BB%80%E9%BA%BC/argocd_architecture_hu7301e8d492990cc775fb267fdb3a75d6_47024_480x0_resize_q75_h2_box_2.webp 480w, https://yue-jenny.github.io/2023/01/argo-cd-%E6%98%AF%E4%BB%80%E9%BA%BC/argocd_architecture_hu7301e8d492990cc775fb267fdb3a75d6_47024_1024x0_resize_q75_h2_box_2.webp 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;argocd architecture, ref: https://argo-cd.readthedocs.io/en/stable/&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;104&#34;
		data-flex-basis=&#34;251px&#34;
	
&gt;&lt;/p&gt;
&lt;h4 id=&#34;有哪些-componentshttpsargo-cdreadthedocsioenstableoperator-manualarchitecture&#34;&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/operator-manual/architecture/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;有哪些 Components？&lt;/a&gt;&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;API Server&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;可以被 Web UI, CLI, 以及 CI/CD systems 介接的 gRPC/REST server&lt;/li&gt;
&lt;li&gt;它有幾項責任
&lt;ul&gt;
&lt;li&gt;應用管理與&lt;code&gt;狀態回報&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;處理 &lt;code&gt;application 的操作&lt;/code&gt;，如 sync, rollback, 其他使用者定義的動作&lt;/li&gt;
&lt;li&gt;管理 &lt;code&gt;credential&lt;/code&gt;，如 K8s secrets&lt;/li&gt;
&lt;li&gt;管理驗證與權限&lt;/li&gt;
&lt;li&gt;執行 &lt;code&gt;RBAC&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Git webhook 事件&lt;/code&gt;的傾聽者/傳送者&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Repository Server&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;管理本地 Git repository 的&lt;code&gt;快取 (Cache)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;當有新增以下參數，需建立 Kubernetes manifests
&lt;ul&gt;
&lt;li&gt;repository URL&lt;/li&gt;
&lt;li&gt;revision (commit, tag, branch)&lt;/li&gt;
&lt;li&gt;application path&lt;/li&gt;
&lt;li&gt;template specific settings: parameters, helm values.yaml&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Application Controller&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;屬於 &lt;code&gt;Kubernetes controller&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;更多關於 &lt;a class=&#34;link&#34; href=&#34;https://kubernetes.io/docs/concepts/architecture/controller/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Kubernetes controller&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;持續偵測運行中的 application，並比較&lt;code&gt;現在狀態&lt;/code&gt;與&lt;code&gt;目標狀態&lt;/code&gt;，若偵測到 &lt;code&gt;OutOfSync&lt;/code&gt; 則會選擇性採取正確動作&lt;/li&gt;
&lt;li&gt;此元件負責為生命週期事件(PreSync, Sync, PostSync)去調用使用者定義的 hooks&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;features&#34;&gt;Features&lt;/h3&gt;
&lt;p&gt;根據提供的功能，可以將其分為以下幾項：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;部署和管理功能：&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;自動部署應用程序到指定的目標環境&lt;/li&gt;
&lt;li&gt;支持多個配置管理/模板工具（Kustomize、Helm、Jsonnet、純YAML）&lt;/li&gt;
&lt;li&gt;能夠管理和部署到多個集群&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;2&#34;&gt;
&lt;li&gt;身份驗證和安全功能：&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;SSO集成（OIDC、OAuth2、LDAP、SAML 2.0、GitHub、GitLab、Microsoft、LinkedIn）&lt;/li&gt;
&lt;li&gt;多租戶和RBAC策略用於授權&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;3&#34;&gt;
&lt;li&gt;回滾和配置管理功能：&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;回滾/任意回滾到Git存儲庫中提交的任何應用程序配置&lt;/li&gt;
&lt;li&gt;應用程序資源的健康狀態分析&lt;/li&gt;
&lt;li&gt;自動配置漂移檢測和可視化&lt;/li&gt;
&lt;li&gt;自動或手動將應用程序同步到所需狀態&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;4&#34;&gt;
&lt;li&gt;用戶界面和集成功能：&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;提供實時應用程序活動的Web UI&lt;/li&gt;
&lt;li&gt;命令行界面（CLI）用於自動化和CI集成&lt;/li&gt;
&lt;li&gt;Webhook集成（GitHub、BitBucket、GitLab）&lt;/li&gt;
&lt;li&gt;用於自動化的訪問令牌(Access token)&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start=&#34;5&#34;&gt;
&lt;li&gt;應用程序升級和監控功能：&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;支持 PreSync、Sync、PostSync 鉤子以支持複雜的應用程序升級（例如藍/綠和金絲雀升級）&lt;/li&gt;
&lt;li&gt;應用程序事件和API調用的軌跡&lt;/li&gt;
&lt;li&gt;Prometheus metrics&lt;/li&gt;
&lt;li&gt;可覆蓋 Helm 參數的參數覆蓋&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;支援的功能繁多，列出一部分。每一版或者會有些不同，建議可參考&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/#features&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;這些功能可幫助團隊實現自動化部署、安全驗證、配置管理、回滾、監控等在持續交付環境中必要的任務。&lt;/p&gt;
&lt;h2 id=&#34;心得&#34;&gt;心得&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Argo CD 在 March 26, 2020 被 CNCF 列入，CNCF 的專案們整合程度越來越高，相信未來的多數公司的 CICD、監控、Log、角色權限控管、資料庫等會以 CNCF 專案為主。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;若想知道如何在 docker desktop 建立 Argo CD，請參考文章&lt;a class=&#34;link&#34; href=&#34;../argocd-on-docker-desktop/&#34; &gt;【使用 Docker Desktop 運行 Argo CD】&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;參考資料&#34;&gt;參考資料&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Argo CD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/operator-manual/architecture/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Argo CD Components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://kubernetes.io/docs/concepts/architecture/controller/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Kubernetes Controllers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/getting_started/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;getting started guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/user-guide/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;user oriented documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/developer-guide/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Developer oriented documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/operator-manual/upgrading/overview/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;the upgrade guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;最後，若喜歡我的分享，可以免費幫我按讚，是對我最大的鼓勵!&lt;/strong&gt;&lt;/p&gt;
</description>
        </item>
        <item>
        <title>使用 Docker Desktop 運行 Argo CD 以及在 Argo CD 內建立 App 偵測 repository 狀態</title>
        <link>https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/</link>
        <pubDate>Wed, 04 Jan 2023 04:39:13 +0000</pubDate>
        
        <guid>https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/</guid>
        <description>&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;開始前，需要先確保有以下的先備知識&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://kubernetes.io/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;kubernetes&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;argo-cd-介紹&#34;&gt;Argo CD 介紹&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;以 GitOps 模式為宗旨的持續部屬 (continuous delivery) 工具
&lt;ul&gt;
&lt;li&gt;關於 GitOps 可以參考文章 &lt;a class=&#34;link&#34; href=&#34;../what-is-gitops-pattern/&#34; &gt;GitOps&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;getting-started-with-argo-cd-on-docker-desktop&#34;&gt;Getting Started with Argo CD on Docker Desktop&lt;/h2&gt;
&lt;p&gt;讓我們一步一步開始吧! 💪&lt;/p&gt;
&lt;h3 id=&#34;建立-namespace&#34;&gt;建立 namespace&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-SHELL&#34; data-lang=&#34;SHELL&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;kubectl create namespace argocd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;安裝-argo-cd-的-kubernetes-resources&#34;&gt;安裝 Argo CD 的 kubernetes resources&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;需要安裝的 resources 都寫在 install.yaml 內，利用 &lt;code&gt;kubectl apply&lt;/code&gt; 指令進行安裝&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-SHELL&#34; data-lang=&#34;SHELL&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;確認-argo-cd-的-pod-的運行狀態為-running&#34;&gt;確認 Argo CD 的 pod 的運行狀態為 running&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;-n&lt;/code&gt; 表示指定 namespace 為 argocd，沒設定就是 default namespace&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-SHELL&#34; data-lang=&#34;SHELL&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;kubectl get pod -n argocd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;pod 運行狀態&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/get-pod-n-argocd.jpg&#34;
	width=&#34;850&#34;
	height=&#34;189&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/get-pod-n-argocd_hue72648a3aa0105e4010abdc11108abb9_48197_480x0_resize_q75_box.jpg 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/get-pod-n-argocd_hue72648a3aa0105e4010abdc11108abb9_48197_1024x0_resize_q75_box.jpg 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;argocd 相關的 pod 都已是 running 狀態&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;449&#34;
		data-flex-basis=&#34;1079px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;取得-argo-cd-初始-admin-的密碼&#34;&gt;取得 Argo CD 初始 admin 的密碼&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;登入 dashboard 使用&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-SHELL&#34; data-lang=&#34;SHELL&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;{.data.password}&amp;#34;&lt;/span&gt; | base64 -d; echo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;將-service-argocd-server-port-forward-到本地&#34;&gt;將 service argocd-server port forward 到本地&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;將 service argocd-server 的 port 443 導至&lt;strong&gt;本地 port 8000&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-SHELL&#34; data-lang=&#34;SHELL&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;kubectl port-forward svc/argocd-server -n argocd 8000:443
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;port forward 成功&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/port-forward.jpg&#34;
	width=&#34;748&#34;
	height=&#34;339&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/port-forward_huabd24b4c8f56be51fa0779e4ac514db3_51986_480x0_resize_q75_box.jpg 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/port-forward_huabd24b4c8f56be51fa0779e4ac514db3_51986_1024x0_resize_q75_box.jpg 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;port forward 成功&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;220&#34;
		data-flex-basis=&#34;529px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;登入-argo-cd-dashboard&#34;&gt;登入 Argo CD dashboard&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;網址輸入 &lt;a class=&#34;link&#34; href=&#34;https://localhost:8000&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;&lt;code&gt;https://localhost:8000&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;成功登入 Argo CD dashboard&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/argocd-dashboard-clean.png&#34;
	width=&#34;1071&#34;
	height=&#34;638&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/argocd-dashboard-clean_hubf35350a067953686ac0ffaa070558e3_60462_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/argocd-dashboard-clean_hubf35350a067953686ac0ffaa070558e3_60462_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;成功登入 Argo CD dashboard&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;167&#34;
		data-flex-basis=&#34;402px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;針對-public-git-repository-建立一組-application&#34;&gt;針對 public git repository 建立一組 application&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;先 fork &lt;a class=&#34;link&#34; href=&#34;https://github.com/argoproj/argocd-example-apps&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;範例 repository - argocd-example-apps&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;依照&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/getting_started/#creating-apps-via-ui&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件指示步驟&lt;/a&gt;進行新增 application&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Step 1
&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/new-app.png&#34;
	width=&#34;638&#34;
	height=&#34;158&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/new-app_hu49baf9f48e5f3f774443692722b5a225_19254_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/new-app_hu49baf9f48e5f3f774443692722b5a225_19254_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;NEW APP&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;403&#34;
		data-flex-basis=&#34;969px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Step 2，填完資訊，按下 &lt;code&gt;CREATE&lt;/code&gt;，能在 dashboard 看到 application&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;app name: guestbook&lt;/li&gt;
&lt;li&gt;project: default&lt;/li&gt;
&lt;li&gt;sync policy: Manual&lt;/li&gt;
&lt;li&gt;Repository URL&lt;/li&gt;
&lt;li&gt;Revision: HEAD&lt;/li&gt;
&lt;li&gt;Path: guestbook&lt;/li&gt;
&lt;li&gt;Destination/Cluster: &lt;code&gt;https://kubernetes.default.svc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Namespace: default&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;針對-private-git-repository-建立一組-application&#34;&gt;針對 private git repository 建立一組 application&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;選一組 private repo&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;到 &lt;code&gt;Settings/Repositories&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/setting-private-repo.png&#34;
	width=&#34;814&#34;
	height=&#34;353&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/setting-private-repo_hu78a555d7bb85e8a49707de97e637f012_33877_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/setting-private-repo_hu78a555d7bb85e8a49707de97e637f012_33877_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;Settings/Repositories&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;230&#34;
		data-flex-basis=&#34;553px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;以 &lt;code&gt;ssh-key&lt;/code&gt; 方式認證，也能選擇以 &lt;code&gt;Https&lt;/code&gt;或者 &lt;code&gt;Github App&lt;/code&gt; 的方式驗證&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;可參考&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/user-guide/private-repositories/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Argo CD Private Repositories Credential 設定&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;可參考我的文章&lt;a class=&#34;link&#34; href=&#34;../%e5%9c%a8-argo-cd-%e4%b8%ad%e4%bd%bf%e7%94%a8-github-app-credential-%e4%bd%9c%e7%82%ba%e9%a9%97%e8%ad%89%e6%96%b9%e5%bc%8f/&#34; &gt;使用 Github App Credential 認證&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;設定完成會顯示 &lt;code&gt;Successful&lt;/code&gt;
&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/ssh-key-auth.png&#34;
	width=&#34;1060&#34;
	height=&#34;210&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/ssh-key-auth_huabe8ed2476538e932deefecd450f8e3f_14786_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/ssh-key-auth_huabe8ed2476538e932deefecd450f8e3f_14786_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;以 ssh-key 方式認證&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;504&#34;
		data-flex-basis=&#34;1211px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;建立 application&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Step 1
&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/new-app.png&#34;
	width=&#34;638&#34;
	height=&#34;158&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/new-app_hu49baf9f48e5f3f774443692722b5a225_19254_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/new-app_hu49baf9f48e5f3f774443692722b5a225_19254_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;NEW APP&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;403&#34;
		data-flex-basis=&#34;969px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Step 2&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;依照&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/getting_started/#creating-apps-via-ui&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件指示步驟&lt;/a&gt;填入資料
&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/add-info-and-create.png&#34;
	width=&#34;1021&#34;
	height=&#34;815&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/add-info-and-create_hu338b5f90a6ef44a979a415c69ad0440f_40531_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/add-info-and-create_hu338b5f90a6ef44a979a415c69ad0440f_40531_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;填入資料並 CREATE&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;125&#34;
		data-flex-basis=&#34;300px&#34;
	
&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;成功建立一組 private application 🚀&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/enter-argocd-dshaboard-successfully.jpg&#34;
	width=&#34;1023&#34;
	height=&#34;581&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/enter-argocd-dshaboard-successfully_hu2f9e0fec8e3eb44dc7df0f48b6ca8d80_56232_480x0_resize_q75_box.jpg 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/enter-argocd-dshaboard-successfully_hu2f9e0fec8e3eb44dc7df0f48b6ca8d80_56232_1024x0_resize_q75_box.jpg 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;成功建立一組 application&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;176&#34;
		data-flex-basis=&#34;422px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;解除安裝-application&#34;&gt;解除安裝 application&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;執行 &lt;code&gt;DELETE&lt;/code&gt; 按鈕&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/delete-app.png&#34;
	width=&#34;531&#34;
	height=&#34;328&#34;
	srcset=&#34;https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/delete-app_hu66f4bb314802a66182a28a7e0c029fae_30154_480x0_resize_box_3.png 480w, https://yue-jenny.github.io/2023/01/%E4%BD%BF%E7%94%A8-docker-desktop-%E9%81%8B%E8%A1%8C-argo-cd-%E4%BB%A5%E5%8F%8A%E5%9C%A8-argo-cd-%E5%85%A7%E5%BB%BA%E7%AB%8B-app-%E5%81%B5%E6%B8%AC-repository-%E7%8B%80%E6%85%8B/delete-app_hu66f4bb314802a66182a28a7e0c029fae_30154_1024x0_resize_box_3.png 1024w&#34;
	loading=&#34;lazy&#34;
	
		alt=&#34;DELETE 按鈕&#34;
	
	
		class=&#34;gallery-image&#34; 
		data-flex-grow=&#34;161&#34;
		data-flex-basis=&#34;388px&#34;
	
&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;解除安裝-argo-cd&#34;&gt;解除安裝 Argo CD&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;⚠️ 解除安裝 Argo CD 前&lt;strong&gt;一定要先解除安裝 application&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;kubectl -n argocd delete -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;遇過的問題&#34;&gt;遇過的問題&lt;/h3&gt;
&lt;h2 id=&#34;參考資料&#34;&gt;參考資料&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Argo CD&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/getting_started/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Argo CD getting started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://collabnix.com/getting-started-with-argocd-on-docker-desktop/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;參考文件&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://kubernetes.io/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;kubernetes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://kubernetes.io/zh-cn/docs/tasks/access-application-cluster/port-forward-access-application-cluster/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;kubectl port-forward&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://argo-cd.readthedocs.io/en/stable/user-guide/private-repositories/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Argo CD Private Repositories Credential 設定&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;🍀 最後，若喜歡我的分享，可以免費幫我按讚，是對我最大的鼓勵! ✨ ✨ ✨&lt;/strong&gt;&lt;/p&gt;
</description>
        </item>
        <item>
        <title>如何使用 Github Workflow 完成 CI/CD</title>
        <link>https://yue-jenny.github.io/2022/12/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8-github-workflow-%E5%AE%8C%E6%88%90-ci/cd/</link>
        <pubDate>Sat, 10 Dec 2022 18:33:05 +0800</pubDate>
        
        <guid>https://yue-jenny.github.io/2022/12/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8-github-workflow-%E5%AE%8C%E6%88%90-ci/cd/</guid>
        <description>&lt;h2 id=&#34;github-workflow-介紹&#34;&gt;Github Workflow 介紹&lt;/h2&gt;
&lt;h3 id=&#34;前言&#34;&gt;前言&lt;/h3&gt;
&lt;p&gt;為了利用 Github Workflow 完成 CI/CD，分成幾個部分來寫，分別是&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Github Workflow 的基本設定&lt;/li&gt;
&lt;li&gt;Github Workflow 中進行 CI&lt;/li&gt;
&lt;li&gt;登入登出 AWS ECR 與 github container registry&lt;/li&gt;
&lt;li&gt;build &amp;amp; upload image&lt;/li&gt;
&lt;li&gt;更新 helm value 中的 image tag，後續讓 argocd 得以偵測到 helm values 的變化後，進行自動化部屬&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;基本設定&#34;&gt;基本設定&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;action 為 &lt;code&gt;push&lt;/code&gt; 的時候，&lt;code&gt;所有 branch&lt;/code&gt; 都會進行 github workflow&lt;/li&gt;
&lt;li&gt;action 為 &lt;code&gt;pull_request&lt;/code&gt; 的時候，只有 &lt;code&gt;main branch&lt;/code&gt; 會進行 github workflow&lt;/li&gt;
&lt;li&gt;types&lt;/li&gt;
&lt;li&gt;paths&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;on:
  push:
    branches: [&amp;#34;*&amp;#34;]
  pull_request:
    branches: [&amp;#34;main&amp;#34;]
    types:
      - opened
    paths:
      - &amp;#34;**.js&amp;#34;
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;env-設定&#34;&gt;env 設定&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;設定方式如下，可以依照自身需求進行設定&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;env:
  AWS_DEFAULT_REGION: ap-southeast-1
  GIT_USER_NAME: jennyc
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;permissions-設定&#34;&gt;permissions 設定&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;設定方式如下，可以依照自身需求進行設定&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;permissions:
  id-token: write # This is required for requesting the JWT
  contents: read # This is required for actions/checkout
&lt;/code&gt;&lt;/pre&gt;&lt;!-- raw HTML omitted --&gt;
&lt;h2 id=&#34;自動化測試-ci&#34;&gt;自動化測試 CI&lt;/h2&gt;
&lt;h3 id=&#34;checkout-repository&#34;&gt;checkout repository&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;使用 &lt;code&gt;actions/checkout@v3&lt;/code&gt; 進行&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- name: Checkout repository
  uses: actions/checkout@v3
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;執行-npm-install&#34;&gt;執行 npm install&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- name: Install dependencies
  run: npm install
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;執行-npm-test&#34;&gt;執行 npm test&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- name: Run tests
  run: npm run test
&lt;/code&gt;&lt;/pre&gt;&lt;!-- raw HTML omitted --&gt;
&lt;h2 id=&#34;build-multi-platform-images-並上傳至-aws-ecr&#34;&gt;Build multi-platform images 並上傳至 AWS ECR&lt;/h2&gt;
&lt;h3 id=&#34;前言-1&#34;&gt;前言&lt;/h3&gt;
&lt;p&gt;這部分需要先設定 AWS Credential 才能使用 AWS ECR，&lt;br&gt;
接著 build multi-platform image 並且上傳至 AWS ECR。&lt;/p&gt;
&lt;h3 id=&#34;1-設定-aws-credential&#34;&gt;1. 設定 AWS Credential&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;設定 AWS Credential&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;使用 GitHub&amp;rsquo;s OIDC provider 方式取得 short-lived credentials&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;OpenID Connect (OIDC) 設定方式可以&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;參考官方文件&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;也可以參考這篇&lt;a class=&#34;link&#34; href=&#34;../how-to-use-oidc-to-auth-aws-services/&#34; &gt;文章&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;workflow 要怎麼寫?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;env.AWS_DEFAULT_REGION&lt;/code&gt; 需要特別設定，與 AWS ECR 相同的 region&lt;/li&gt;
&lt;li&gt;&lt;code&gt;role-to-assume&lt;/code&gt; 填入 AWS role&lt;/li&gt;
&lt;li&gt;&lt;code&gt;role-session-name&lt;/code&gt; 預設是 GitHubActions，可以自行調整名稱&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  - name: Configure AWS credentials
    uses: aws-actions/configure-aws-credentials@v1
    with:
        role-to-assume: arn:aws:iam::1234567890:role/example-role
        role-session-name: GitHubActionsWithAwsEcrUsingOIDCSession 
        aws-region: ${{env.AWS_DEFAULT_REGION}}
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;2-登入-aws-private-ecr&#34;&gt;2. 登入 AWS private ECR&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;有兩種方式
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Using &lt;code&gt;access key id&lt;/code&gt; and &lt;code&gt;secret access key&lt;/code&gt; to login&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  - name: Configure AWS credentials
    uses: aws-actions/configure-aws-credentials@v1
    with:
      aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      aws-region: ap-southeast-1
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Using &lt;code&gt;OpenID Connect (OIDC)&lt;/code&gt; to login&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;官方推薦使用此方式&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  - name: Login to Amazon ECR
    id: login-ecr
    uses: aws-actions/amazon-ecr-login@v1
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;3-登入-aws-public-ecr&#34;&gt;3. 登入 AWS public ECR&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;可參考&lt;a class=&#34;link&#34; href=&#34;https://github.com/aws-actions/amazon-ecr-login#login-to-amazon-ecr-public-then-package-and-push-a-helm-chart&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方說明&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;4-登出-aws-ecr&#34;&gt;4. 登出 AWS ECR&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- name: Logout of Amazon ECR
  if: always()
  run: docker logout ${{ steps.login-ecr.outputs.registry }}
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;5-設定-short-sha-為-image-tag&#34;&gt;5. 設定 short sha 為 image tag&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;設定以 7 digits 長度的 short sha 作為 image tag，原因可以參考:
&lt;ul&gt;
&lt;li&gt;7 digits are the Git default for a short SHA&lt;/li&gt;
&lt;li&gt;附上其他參考文件 &lt;a class=&#34;link&#34; href=&#34;http://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Chapter 7 of the Pro Git book&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;將 output 出去的參數命名為 &lt;code&gt;sha_short&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;      - name: Set short sha outputs
        id: vars
        run: echo &amp;#34;sha_short=$(git rev-parse --short HEAD)&amp;#34; &amp;gt;&amp;gt; $GITHUB_OUTPUT
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;6-build-multi-platform-images-並上傳-images-到-aws-ecr&#34;&gt;6. Build multi-platform images 並上傳 images 到 AWS ECR&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;建立多平台 docker images 的&lt;a class=&#34;link&#34; href=&#34;https://docs.docker.com/build/building/multi-platform/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;IMAGE_TAG&lt;/code&gt; 會從&lt;a class=&#34;link&#34; href=&#34;./#5-%e8%a8%ad%e5%ae%9a-short-sha-%e7%82%ba-image-tag&#34; &gt;步驟 5&lt;/a&gt; 取得 output 的變數 &lt;code&gt;sha_short&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--platform&lt;/code&gt; 可接上需要的 platform 參考，例如 linux/amd64, linux/arm64&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  - name: Build, tag, and push docker image to Amazon ECR
    env:
        REGISTRY: ${{ steps.login-ecr.outputs.registry }}
        REPOSITORY: pet-app
        IMAGE_TAG: ${{ steps.vars.outputs.sha_short }}
    run: |
        docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
        ( 官方建議: docker run --privileged --rm tonistiigi/binfmt --install all )
        docker buildx create --name mybuilder --driver docker-container --bootstrap
        docker buildx use mybuilder
        docker buildx inspect
        docker buildx build --platform linux/amd64,linux/arm64 -t $REGISTRY/$REPOSITORY:$IMAGE_TAG --push .
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;為什麼需要 &lt;code&gt;docker run --rm --privileged multiarch/qemu-user-static --reset -p yes&lt;/code&gt;&lt;/strong&gt; ?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;因為遇到 &lt;code&gt;Error: while loading /usr/local/sbin/node: No such file or directory&lt;/code&gt; 問題
&lt;ul&gt;
&lt;li&gt;先使用方式一 : &lt;a class=&#34;link&#34; href=&#34;https://blog.csdn.net/wmg13178599398/article/details/127605036&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;連接方式&lt;/a&gt;，結果還是有相同問題
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  ln -s /usr/bin/node /usr/local/sbin/node
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;後來使用&lt;a class=&#34;link&#34; href=&#34;https://stackoverflow.com/questions/72167570/docker-buildx-nodejs-fail&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;方式二&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;使用 docker buildx 指令前&lt;strong&gt;先執行以下命令&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://stackoverflow.com/questions/57178788/docker-build-fails-for-arm-images/57183566#57183566&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;詳細原因的 Stack Overflow 原始文章在這邊，以下是節錄部分&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;`
When you ask the Linux kernel to run some executable file, it needs to know, how to load this specific file, and whether this file is compatible with current machine, or not. By default, the ELF binary compiled for, say, arm64v8 is rejected by the kernel, running on amd64 hardware.&lt;/p&gt;
&lt;p&gt;However, the binfmt_misc feature of the kernel allows you to tell it, how to handle the executables it cannot usually handle on its own - this includes the cases when the kernel does not know the binary format or considers it incompatible with current machine.&lt;br&gt;
`&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/docker/buildx/issues/495&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;github issue&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;官方建議使用以下命令解決 QEMU binaries 問題，&lt;a class=&#34;link&#34; href=&#34;https://docs.docker.com/build/building/multi-platform/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  docker run --privileged --rm tonistiigi/binfmt --install all
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- raw HTML omitted --&gt;
&lt;h2 id=&#34;更新-helm-value-的-image-tag&#34;&gt;更新 helm value 的 image tag&lt;/h2&gt;
&lt;h3 id=&#34;前言-2&#34;&gt;前言&lt;/h3&gt;
&lt;p&gt;應用是以 terraform 方式部屬，並搭配使用 helm charts。而 docker image 的 tag 是寫在 helm values 內。&lt;br&gt;
目標是更新 helm values 的 docker image tag 值，後續讓 argocd 得以偵測到 helm values 的變化後，進行自動化部屬。&lt;/p&gt;
&lt;p&gt;需做到兩件事情:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;checkout 私有 repository&lt;/li&gt;
&lt;li&gt;設定與更新 image tag&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&#34;1-先-checkout-私有存放-helm-value-的-repository&#34;&gt;1. 先 checkout 私有存放 helm value 的 repository&lt;/h3&gt;
&lt;p&gt;需要先設定 credential 才能 fetch private repository，有兩種設定的方式&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;設定 deploy key&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;步驟如下，可參考&lt;a class=&#34;link&#34; href=&#34;https://stackoverflow.com/questions/60222741/github-actions-and-git-clone-issue&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;這篇&lt;/a&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Create a new SSH key pair&lt;/a&gt; for your repository. Do not set a passphrase.&lt;/li&gt;
&lt;li&gt;Copy the contents of the public key (.pub file) to a new repository &lt;a class=&#34;link&#34; href=&#34;https://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;deploy key&lt;/a&gt; and check the box to &amp;ldquo;Allow write access.&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Add a secret to the repository containing the entire contents of the private key.&lt;/li&gt;
&lt;li&gt;As shown in the example below, configure &lt;code&gt;actions/checkout&lt;/code&gt; to use the deploy key you have created.&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;workflow 要怎麼寫?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ssh-key 填入 private key 的 secrets 名稱&lt;/li&gt;
&lt;li&gt;path 設定 checkout 的 repo 會存在哪一個資料夾內&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;  - name: Checkout ${{env.TERRAFORM_REPOSITORY_NAME}} repo and push file to ${{env.TERRAFORM_REPOSITORY_NAME}}
    uses: actions/checkout@v3
    with:
      repository: ${{env.TERRAFORM_REPOSITORY_OWNER_NAME}}/${{env.TERRAFORM_REPOSITORY_NAME}}
      ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
      path: ${{env.TERRAFORM_REPOSITORY_NAME}}
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;設定 Personal access token (PAT)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;建立 PAT 的方式，&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;將建立完成的 PAT 設定到 repository 的 secrets 中，設定的 secrets 名稱為 GH_PAT，&lt;a class=&#34;link&#34; href=&#34;https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;官方文件&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;workflow 要怎麼寫?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;repository 設定為 &lt;code&gt;owner/repository_name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;token 填入 PAT 的 secrets 名稱，這邊是將 secrets 名稱為 GH_PAT 的內容設定為 PAT&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- name: Checkout ${{env.TERRAFORM_REPOSITORY_NAME}} repo and push file to ${{env.TERRAFORM_REPOSITORY_NAME}}
    uses: actions/checkout@v3
    with:
        repository: ${{env.TERRAFORM_REPOSITORY_OWNER_NAME}}/${{env.TERRAFORM_REPOSITORY_NAME}}
        token: ${{ secrets.GH_PAT }}
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;2-設定-image-tag&#34;&gt;2. 設定 image tag&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;設定以 7 digits 長度的 short sha 作為 image tag
&lt;ul&gt;
&lt;li&gt;7 digits are the Git default for a short SHA&lt;/li&gt;
&lt;li&gt;附上其他參考文件 &lt;a class=&#34;link&#34; href=&#34;http://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Chapter 7 of the Pro Git book&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;      - name: Set short sha outputs
        id: vars
        run: echo &amp;#34;sha_short=$(git rev-parse --short HEAD)&amp;#34; &amp;gt;&amp;gt; $GITHUB_OUTPUT
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;3-更新-image-tag&#34;&gt;3. 更新 image tag&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;以 yq 的 github action 工具修改 yaml 檔內的 image tag 值
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://mikefarah.gitbook.io/yq/v/v3.x/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;yq 的官方文件&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/mikefarah/yq&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;yq 的 github&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;進行 git 操作，設定 user name, user email、commit 以及 push&lt;/li&gt;
&lt;li&gt;tag 取上一個步驟 output 的參數 &lt;code&gt;sha_short&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;      - name: Update image tag
        uses: mikefarah/yq@master
        with:
          cmd: yq -i &amp;#39;.pet_app_dashboard_site.image.tag = &amp;#34;${{ steps.vars.outputs.sha_short }}&amp;#34;&amp;#39; ./${{env.TERRAFORM_REPOSITORY_NAME}}/${{env.HELM_FILE_NAME}}
      - run: |
          cd ${{env.TERRAFORM_REPOSITORY_NAME}}
          git config user.name ${{env.GIT_USER_NAME}}
          git config user.email ${{env.GIT_USER_EMAIL}}
          git add ${{env.HELM_FILE_NAME}}
          git commit -m &amp;#34;update image tag to ${{ steps.vars.outputs.sha_short }}&amp;#34;
          git push origin main
&lt;/code&gt;&lt;/pre&gt;&lt;!-- raw HTML omitted --&gt;
&lt;h2 id=&#34;若要將-docker-image-上傳至-github-container-registry-該怎麼做&#34;&gt;若要將 docker image 上傳至 github container registry 該怎麼做?&lt;/h2&gt;
&lt;h3 id=&#34;1-登入與登出-github-container-registry&#34;&gt;1. 登入與登出 github container registry&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;需要設定 env.REGISTRY 為 ghcr.io&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;不需要另外設定 github.actor 與 &lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/actions/security-guides/automatic-token-authentication&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;GITHUB_TOKEN&lt;/a&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;    - name: Login to GitHub Container Registry
      uses: docker/login-action@v2
      with:
      registry: ${{ env.REGISTRY }}
      username: ${{ github.actor }}
      password: ${{ secrets.GITHUB_TOKEN }}
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&#34;2-extract-metadata&#34;&gt;2. Extract metadata&lt;/h3&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
        with:
          images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;3-build-and-push-docker-image&#34;&gt;3. Build and push docker image&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;labels 的值可以從步驟二取出 outputs labels 來使用&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;      - name: Build and push Docker image
        uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
        with:
          context: .
          push: true
          tags: ${{ env.REGISTRY }}/${{ env.REPO }}:${{ steps.vars.outputs.sha_short }}
          labels: ${{ steps.meta.outputs.labels }}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;參考資料&#34;&gt;參考資料&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/actions/checkout&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;actions/checkout&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/aws-actions/amazon-ecr-login&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;amazon-ecr-login&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/docker/login-action&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;docker/login-action&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://stackoverflow.com/questions/57178788/docker-build-fails-for-arm-images/57183566#57183566&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;docker-build-fails-for-arm-images&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://mikefarah.gitbook.io/yq/v/v3.x/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;yq 的官方文件&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/mikefarah/yq&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;yq 的 github&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;http://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;Chapter 7 of the Pro Git book&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;creating-a-personal-access-token&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;creating-and-using-encrypted-secrets&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;最後，若喜歡我的分享，可以免費幫我按讚，是對我最大的鼓勵!&lt;/strong&gt;&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
