From b76163160357748e94ed2a74fa5f54851abc74e5 Mon Sep 17 00:00:00 2001
From: Koy <koy@ko8e24.top>
Date: Tue, 21 May 2024 20:47:31 +0800
Subject: [PATCH 1/3] update: polish pr content

---
 .github/workflows/rotate-emoji.yml | 56 ++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 .github/workflows/rotate-emoji.yml

diff --git a/.github/workflows/rotate-emoji.yml b/.github/workflows/rotate-emoji.yml
new file mode 100644
index 000000000..b37644a51
--- /dev/null
+++ b/.github/workflows/rotate-emoji.yml
@@ -0,0 +1,56 @@
+name: Rotate emojiData
+
+on:
+  schedule:
+    - cron: '0 2 * * *'
+  workflow_dispatch:
+
+concurrency:
+  group: rotate-emoji-group
+
+jobs:
+  sync-emojis-from-github:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          # TODO change to develop
+          ref: rotate-emoji-test-dev
+
+      - name: Setup Node.js v20
+        uses: actions/setup-node@v3
+        with:
+          node-version: 20
+          cache: 'npm'
+
+      - name: Install dependencies
+        run: npm ci --ignore-scripts
+
+      - name: Fetch emojiData
+        run: npm run build:emoji
+
+      - name: Check for changes
+        run: |
+          if git diff --quiet -- "src/core/render/emoji-data.js"; then
+            echo "No changes Found. Skipping PR creation."
+          else
+            echo "Changes detected in emoji-data.js. Creating PR."
+
+            current_date=$(date +'%Y-%m-%d')
+
+            branch_name="update-emoji-data-$current_date"
+            pr_title="update(emoji): sync emojiData and find update emojis in [$current_date]"
+            git config --global user.email "actions@github.com"
+            git config --global user.name "GitHub Actions"
+
+            git checkout -b $branch_name
+            git add src/core/render/emoji-data.js
+            git add docs/emoji.md
+            git commit -m "update(emoji): sync emojiData and find update emojis in [$current_date]"
+            unique_branch_name=$branch_name-$(git log -1 --pretty=%h)
+            git checkout -b $unique_branch_name
+            git push origin $unique_branch_name
+            gh pr create --title "$pr_title" --body "Found updated github emojis need to sync, PTAL @docsifyjs/reviewers :robot:." --base develop
+          fi
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

From e6b59d5b010fe571b48fff8933a74b6ec02a0c44 Mon Sep 17 00:00:00 2001
From: koy <koy@ko8e24.top>
Date: Wed, 22 May 2024 22:28:47 +0800
Subject: [PATCH 2/3] update: change target to dev

---
 .github/workflows/rotate-emoji.yml |  3 ---
 build/emoji.js                     | 14 +++++---------
 package.json                       |  4 ++--
 3 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/rotate-emoji.yml b/.github/workflows/rotate-emoji.yml
index b37644a51..9eb811369 100644
--- a/.github/workflows/rotate-emoji.yml
+++ b/.github/workflows/rotate-emoji.yml
@@ -13,9 +13,6 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-        with:
-          # TODO change to develop
-          ref: rotate-emoji-test-dev
 
       - name: Setup Node.js v20
         uses: actions/setup-node@v3
diff --git a/build/emoji.js b/build/emoji.js
index f1ad8930b..affc5c1e5 100644
--- a/build/emoji.js
+++ b/build/emoji.js
@@ -95,13 +95,9 @@ function writeEmojiJS(emojiData) {
 
 console.info('Build emoji');
 
-try {
-  const emojiData = await getEmojiData();
+const emojiData = await getEmojiData();
 
-  if (emojiData) {
-    writeEmojiPage(emojiData);
-    writeEmojiJS(emojiData);
-  }
-} catch (err) {
-  console.warn(`- Error: ${err.message}`);
-}
+writeEmojiPage(emojiData);
+writeEmojiJS(emojiData);
+
+console.info('Finish update');
diff --git a/package.json b/package.json
index 32fb9c412..ced801bc4 100644
--- a/package.json
+++ b/package.json
@@ -28,7 +28,7 @@
     "build:css": "mkdirp lib/themes && node build/css -o lib/themes",
     "build:emoji": "node ./build/emoji.js",
     "build:js": "cross-env NODE_ENV=production node build/build.js",
-    "build": "run-s clean build:js build:css build:css:min build:cover build:emoji",
+    "build": "run-s clean build:js build:css build:css:min build:cover",
     "clean": "rimraf lib themes _playwright*",
     "dev": "run-p serve:dev watch:*",
     "docker:build:test": "npm run docker:cli -- build:test",
@@ -118,4 +118,4 @@
     "creator",
     "generator"
   ]
-}
+}
\ No newline at end of file

From 7b4f7a3c25abdc9436a037c2622028b7b0860b9b Mon Sep 17 00:00:00 2001
From: koy <koy@ko8e24.top>
Date: Thu, 23 May 2024 09:15:59 +0800
Subject: [PATCH 3/3] update: polish the contents

---
 .../workflows/{rotate-emoji.yml => update-emoji.yml}   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
 rename .github/workflows/{rotate-emoji.yml => update-emoji.yml} (83%)

diff --git a/.github/workflows/rotate-emoji.yml b/.github/workflows/update-emoji.yml
similarity index 83%
rename from .github/workflows/rotate-emoji.yml
rename to .github/workflows/update-emoji.yml
index 9eb811369..53b9857b2 100644
--- a/.github/workflows/rotate-emoji.yml
+++ b/.github/workflows/update-emoji.yml
@@ -1,4 +1,4 @@
-name: Rotate emojiData
+name: Update Emoji
 
 on:
   schedule:
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency:
-  group: rotate-emoji-group
+  group: update-emoji-group
 
 jobs:
   sync-emojis-from-github:
@@ -15,7 +15,7 @@ jobs:
       - uses: actions/checkout@v4
 
       - name: Setup Node.js v20
-        uses: actions/setup-node@v3
+        uses: actions/setup-node@v4
         with:
           node-version: 20
           cache: 'npm'
@@ -36,14 +36,14 @@ jobs:
             current_date=$(date +'%Y-%m-%d')
 
             branch_name="update-emoji-data-$current_date"
-            pr_title="update(emoji): sync emojiData and find update emojis in [$current_date]"
+            pr_title="update(emoji): Sync emoji data with GitHub emoji API [$current_date]"
             git config --global user.email "actions@github.com"
             git config --global user.name "GitHub Actions"
 
             git checkout -b $branch_name
             git add src/core/render/emoji-data.js
             git add docs/emoji.md
-            git commit -m "update(emoji): sync emojiData and find update emojis in [$current_date]"
+            git commit -m "update(emoji): Sync emoji data with GitHub emoji API [$current_date]"
             unique_branch_name=$branch_name-$(git log -1 --pretty=%h)
             git checkout -b $unique_branch_name
             git push origin $unique_branch_name