Skip to content

Commit 6552853

Browse files
update(ci): add update emoji schedule workflow (#2436)
--------- Co-authored-by: Luffy <[email protected]>
1 parent 5febdfd commit 6552853

File tree

3 files changed

+59
-10
lines changed

3 files changed

+59
-10
lines changed

Diff for: .github/workflows/update-emoji.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Update Emoji
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *'
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: update-emoji-group
10+
11+
jobs:
12+
sync-emojis-from-github:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Setup Node.js v20
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci --ignore-scripts
25+
26+
- name: Fetch emojiData
27+
run: npm run build:emoji
28+
29+
- name: Check for changes
30+
run: |
31+
if git diff --quiet -- "src/core/render/emoji-data.js"; then
32+
echo "No changes Found. Skipping PR creation."
33+
else
34+
echo "Changes detected in emoji-data.js. Creating PR."
35+
36+
current_date=$(date +'%Y-%m-%d')
37+
38+
branch_name="update-emoji-data-$current_date"
39+
pr_title="update(emoji): Sync emoji data with GitHub emoji API [$current_date]"
40+
git config --global user.email "[email protected]"
41+
git config --global user.name "GitHub Actions"
42+
43+
git checkout -b $branch_name
44+
git add src/core/render/emoji-data.js
45+
git add docs/emoji.md
46+
git commit -m "update(emoji): Sync emoji data with GitHub emoji API [$current_date]"
47+
unique_branch_name=$branch_name-$(git log -1 --pretty=%h)
48+
git checkout -b $unique_branch_name
49+
git push origin $unique_branch_name
50+
gh pr create --title "$pr_title" --body "Found updated github emojis need to sync, PTAL @docsifyjs/reviewers :robot:." --base develop
51+
fi
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: build/emoji.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,9 @@ function writeEmojiJS(emojiData) {
9595

9696
console.info('Build emoji');
9797

98-
try {
99-
const emojiData = await getEmojiData();
98+
const emojiData = await getEmojiData();
10099

101-
if (emojiData) {
102-
writeEmojiPage(emojiData);
103-
writeEmojiJS(emojiData);
104-
}
105-
} catch (err) {
106-
console.warn(`- Error: ${err.message}`);
107-
}
100+
writeEmojiPage(emojiData);
101+
writeEmojiJS(emojiData);
102+
103+
console.info('Finish update');

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"build:css": "stylus src/themes --out dist/themes --sourcemap",
8787
"build:emoji": "node ./build/emoji.js",
8888
"build:js": "rollup -c",
89-
"build": "run-s clean build:js build:css build:css:min build:cover build:emoji",
89+
"build": "run-s clean build:js build:css build:css:min build:cover",
9090
"clean": "rimraf --glob dist/** themes/** _playwright*/**",
9191
"dev": "run-p serve:dev watch:*",
9292
"docker:build:test": "npm run docker:cli -- build:test",

0 commit comments

Comments
 (0)