Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(ci): add update emoji schedule workflow #2436

Merged
merged 5 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/update-emoji.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Update Emoji

on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:

concurrency:
group: update-emoji-group

jobs:
sync-emojis-from-github:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js v20
uses: actions/setup-node@v4
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 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 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
gh pr create --title "$pr_title" --body "Found updated github emojis need to sync, PTAL @docsifyjs/reviewers :robot:." --base develop
Comment on lines +38 to +50
Copy link
Member

@sy-records sy-records May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@Koooooo-7 Koooooo-7 May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for it.
I know those actions but according to our plain needs,using them gonna makes the action more complicated to me.

  1. file change check steps and ::OUTPUT.
  2. commit action on pre if-condition.
  3. pr with change condition with if-condition also.

Personally, I think we could put them together without much actions dependencies for now.

How about we use this now and when we have more requirements on it,we do the refinement then?

fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 5 additions & 9 deletions build/emoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"build:css": "stylus src/themes --out dist/themes --sourcemap",
"build:emoji": "node ./build/emoji.js",
"build:js": "rollup -c",
"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 --glob dist/** themes/** _playwright*/**",
"dev": "run-p serve:dev watch:*",
"docker:build:test": "npm run docker:cli -- build:test",
Expand Down
Loading