From 41e3304d82bcb19e404f61ea405d75b130b53804 Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 13:43:11 +0700 Subject: [PATCH 1/9] feat: add git user --- .github/workflows/deploy.yml | 38 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a9e8a26..c81b9ea 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,25 +3,35 @@ name: Sync and Deploy to Vercel on: push: branches: - - dev + - feat/deploy-preview jobs: sync-and-deploy: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v3 + - name: Checkout Code + uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Push to Personal Repo - env: - PERSONAL_REPO: https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com/korawit-alt/sucu-frontend-preview.git - run: | - git remote add personal $PERSONAL_REPO - git push personal HEAD:dev --force + - name: Set up Git user + run: | + git config user.name "korawit-alt" + git config user.email "test@gmail.com" - - name: Deploy to Vercel - uses: amondnet/vercel-action@v20 - with: - vercel-token: ${{ secrets.VERCEL_TOKEN }} - working-directory: '.' + - name: Mask Personal Access Token + run: | + echo "::add-mask::${{ secrets.PERSONAL_GITHUB_TOKEN }}" + + - name: Push to Personal Repo + run: | + git remote add personal https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com/YOUR_USERNAME/YOUR_PERSONAL_REPO.git + git push personal HEAD:main --force + + - name: Deploy to Vercel + uses: amondnet/vercel-action@v20 + with: + vercel-token: ${{ secrets.VERCEL_TOKEN }} + vercel-args: '--prod' # Deploy to production + working-directory: '.' # Adjust if your project is in a subdirectory From 2d34b690a6ca15a5d3624173e3fd5f4d82dd98ab Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 13:44:04 +0700 Subject: [PATCH 2/9] fix: repo name --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c81b9ea..c53c7d4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,7 +26,7 @@ jobs: - name: Push to Personal Repo run: | - git remote add personal https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com/YOUR_USERNAME/YOUR_PERSONAL_REPO.git + git remote add personal https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com/korawit-alt/sucu-frontend-preview.git git push personal HEAD:main --force - name: Deploy to Vercel From 463bd658d8de0ed889f64c7dced4ea4ea5e2e80e Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 13:47:34 +0700 Subject: [PATCH 3/9] fix: remove default credential --- .github/workflows/deploy.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c53c7d4..5f7c214 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,25 +13,32 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 with: + persist-credentials: false fetch-depth: 0 + - name: Remove default git credentials + run: | + git config --global --unset credential.helper || true + rm -f ~/.git-credentials + - name: Set up Git user run: | - git config user.name "korawit-alt" - git config user.email "test@gmail.com" + git config --global user.name "Hello" + git config --global user.email "test@example.com" - - name: Mask Personal Access Token + - name: Configure Git to use Personal Access Token run: | - echo "::add-mask::${{ secrets.PERSONAL_GITHUB_TOKEN }}" + echo "https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com" > ~/.git-credentials + git config --global credential.helper store - name: Push to Personal Repo run: | - git remote add personal https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com/korawit-alt/sucu-frontend-preview.git - git push personal HEAD:main --force + git remote add personal https://github.com/korawit-alt/sucu-frontend-preview.git + git push personal HEAD:dev --force - name: Deploy to Vercel uses: amondnet/vercel-action@v20 with: vercel-token: ${{ secrets.VERCEL_TOKEN }} - vercel-args: '--prod' # Deploy to production - working-directory: '.' # Adjust if your project is in a subdirectory + vercel-args: '--prod' + working-directory: '.' From 532f4b7a7ccece4c3914dccb88e9552f4453a2bc Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 13:50:33 +0700 Subject: [PATCH 4/9] feat: auto --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5f7c214..ba0f228 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,5 +40,5 @@ jobs: uses: amondnet/vercel-action@v20 with: vercel-token: ${{ secrets.VERCEL_TOKEN }} - vercel-args: '--prod' + vercel-args: '--prod --confirm' working-directory: '.' From 1592cebe71355e495e2c5b929b2bbb43906b4405 Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 13:54:34 +0700 Subject: [PATCH 5/9] refactor: fix lint --- .github/workflows/deploy.yml | 65 ++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dd4e473..3097a4b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,36 +10,35 @@ jobs: runs-on: ubuntu-latest steps: - - - name: Checkout Code - uses: actions/checkout@v3 - with: - persist-credentials: false - fetch-depth: 0 - - - name: Remove default git credentials - run: | - git config --global --unset credential.helper || true - rm -f ~/.git-credentials - - - name: Set up Git user - run: | - git config --global user.name "Hello" - git config --global user.email "test@example.com" - - - name: Configure Git to use Personal Access Token - run: | - echo "https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com" > ~/.git-credentials - git config --global credential.helper store - - - name: Push to Personal Repo - run: | - git remote add personal https://github.com/korawit-alt/sucu-frontend-preview.git - git push personal HEAD:dev --force - - - name: Deploy to Vercel - uses: amondnet/vercel-action@v20 - with: - vercel-token: ${{ secrets.VERCEL_TOKEN }} - vercel-args: '--prod --confirm' - working-directory: '.' \ No newline at end of file + - name: Checkout Code + uses: actions/checkout@v3 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Remove default git credentials + run: | + git config --global --unset credential.helper || true + rm -f ~/.git-credentials + + - name: Set up Git user + run: | + git config --global user.name "Hello" + git config --global user.email "test@example.com" + + - name: Configure Git to use Personal Access Token + run: | + echo "https://x-access-token:${{ secrets.PERSONAL_GITHUB_TOKEN }}@github.com" > ~/.git-credentials + git config --global credential.helper store + + - name: Push to Personal Repo + run: | + git remote add personal https://github.com/korawit-alt/sucu-frontend-preview.git + git push personal HEAD:dev --force + + - name: Deploy to Vercel + uses: amondnet/vercel-action@v20 + with: + vercel-token: ${{ secrets.VERCEL_TOKEN }} + vercel-args: '--prod --confirm' + working-directory: '.' From 41f368570e3dc5bcb84809687c100b0e7ce32da6 Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 14:01:42 +0700 Subject: [PATCH 6/9] chore: add git username --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3097a4b..31548e2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,8 +23,8 @@ jobs: - name: Set up Git user run: | - git config --global user.name "Hello" - git config --global user.email "test@example.com" + git config --global user.name "SUCU Preview Bot" + git config --global user.email "sucu-preview@gmail.com" - name: Configure Git to use Personal Access Token run: | From 0baeb76fbc3f636b660cd92863af76a62e8e17e1 Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 23:35:00 +0700 Subject: [PATCH 7/9] chore: add `PERSONAL_REPO` secrets --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 31548e2..011d558 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -33,7 +33,7 @@ jobs: - name: Push to Personal Repo run: | - git remote add personal https://github.com/korawit-alt/sucu-frontend-preview.git + git remote add personal ${{ secrets.PERSONAL_REPO}} git push personal HEAD:dev --force - name: Deploy to Vercel From 2b43f4aa72cda996a196f61d502d31eae553c7ba Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 23:36:47 +0700 Subject: [PATCH 8/9] fix: `--confirm` is deprecated use `--yes` instead --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 011d558..2532922 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -40,5 +40,5 @@ jobs: uses: amondnet/vercel-action@v20 with: vercel-token: ${{ secrets.VERCEL_TOKEN }} - vercel-args: '--prod --confirm' + vercel-args: '--prod --yes' working-directory: '.' From fad5adcc3d36e288d199318ee2ef2795c216bef1 Mon Sep 17 00:00:00 2001 From: Sirawit Chanaburanasak Date: Sun, 15 Sep 2024 23:39:25 +0700 Subject: [PATCH 9/9] feat: change trigger event to branch `dev` --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2532922..6eca218 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,7 +3,7 @@ name: Sync and Deploy to Vercel on: push: branches: - - feat/deploy-preview + - dev jobs: sync-and-deploy: