|
| 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 "actions@github.com" |
| 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 }} |
0 commit comments