Update emojis #50
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update emojis | |
on: | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: Run the workflow without creating a pull request | |
required: false | |
default: "false" | |
schedule: | |
# https://crontab.guru/#0_0_*/7_*_* | |
- cron: "0 0 */7 * *" | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
permissions: | |
contents: write | |
pull-requests: write | |
if: github.repository_owner == 'luxass' | |
steps: | |
- uses: actions/checkout@v4.1.7 | |
- name: setup pnpm | |
uses: pnpm/action-setup@v4.0.0 | |
- name: setup node | |
uses: actions/setup-node@v4.0.3 | |
with: | |
node-version: 20 | |
- name: install dependencies | |
run: pnpm install | |
- name: save old emoji-urls file | |
run: cp emoji-urls.json /tmp/old-emoji-urls.json | |
- name: run update:emojis script | |
run: pnpm run update:emojis | |
- name: process emoji changes | |
id: emoji_changes | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { readFileSync } = require('fs'); | |
const oldEmojiUrls = JSON.parse(readFileSync('/tmp/old-emoji-urls.json', 'utf8')); | |
const newEmojiUrls = JSON.parse(readFileSync('emoji-urls.json', 'utf8')); | |
const changes = Object.keys(newEmojiUrls).reduce((acc, key) => { | |
if (oldEmojiUrls[key] !== newEmojiUrls[key]) { | |
acc[key] = newEmojiUrls[key] | |
} | |
return acc; | |
}, {}); | |
let changesTable = ''; | |
for (let i = 0; i < Object.keys(changes).length; i += 3) { | |
const key1 = Object.keys(changes)[i]; | |
const key2 = Object.keys(changes)[i + 1]; | |
const key3 = Object.keys(changes)[i + 2]; | |
changesTable += `| :${key1}: | ${key2 != null ? ':' + key2 + ':' : ''} | ${key3 != null ? ':' + key3 + ':' : ''} |\n`; | |
} | |
if (Object.keys(changes).length === 0) { | |
core.setOutput('changes', 'false'); | |
} else { | |
core.setOutput('changes', 'true'); | |
core.setOutput('changes-table', changesTable) | |
} | |
- name: create pull request | |
uses: peter-evans/create-pull-request@v6.1.0 | |
if: ${{ github.event.inputs.dry-run != 'true' && steps.emoji_changes.outputs.changes == 'true' }} | |
with: | |
commit-message: "chore: updated emojis" | |
title: "chore: updated github emojis" | |
body: | | |
I found some new changes in GitHub's list of emojis. | |
<details> | |
<summary>Here you can see a list of the new emojis</summary> | |
| Emoji | Emoji | Emoji | | |
| ----- | ----- | ----- | | |
${{ steps.emoji_changes.outputs.changes-table }} | |
</details> | |
I don't know which emoji they changed or added, but I'm sure it's cool. | |
If you want you can go take a look yourself. | |
I will be waiting for your approval 👋. | |
This is an automated PR to update the GitHub Emoji List. | |
If you have any questions or suggestions, please open an issue. | |
branch: update-emojis | |
base: main | |
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | |
reviewers: luxass | |
- name: upload new emojis as artifact | |
uses: actions/upload-artifact@v4.3.4 | |
if: steps.emoji_changes.outputs.changes == 'true' | |
with: | |
name: new-github-emojis | |
path: emoji-urls.json |