Skip to content

Commit 7bedde0

Browse files
committed
chore: update emoji-data-updater workflow
- Set working directory within the workflow. - Remove redundant working directory changes.
1 parent e994f22 commit 7bedde0

File tree

3 files changed

+49
-35
lines changed

3 files changed

+49
-35
lines changed

.github/workflows/emoji-data-updater.yml

+42-33
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,53 @@ jobs:
99
update-emoji-json:
1010
runs-on: ubuntu-latest
1111
env:
12-
VERSION: ''
13-
RELEASE_URL: ''
14-
WORKING_DIR: scripts/emoji_generator
12+
VERSION: ""
13+
RELEASE_URL: ""
14+
defaults:
15+
run:
16+
working-directory: scripts/emoji_generator
1517
steps:
16-
- name: Checkout Repository
17-
uses: actions/checkout@v4
18-
- name: Fetch Latest Emojibase Version
19-
id: fetch_version
20-
run: |
18+
- uses: actions/create-github-app-token@v1
19+
id: app-token
20+
with:
21+
app-id: ${{ secrets.APP_ID }}
22+
private-key: ${{ secrets.APP_PRIVATE_KEY }}
23+
- name: Checkout Repository
24+
uses: actions/checkout@v4
25+
- name: Fetch Latest Emojibase Version
26+
id: fetch_version
27+
run: |
2128
RELEASE_INFO=$(curl -s https://api.github.com/repos/milesj/emojibase/releases/latest)
2229
LATEST_RELEASE=$(echo "$RELEASE_INFO" | jq -r '.tag_name')
2330
RELEASE_URL=$(echo "$RELEASE_INFO" | jq -r '.html_url')
2431
echo "VERSION=$(echo \"$LATEST_RELEASE\" | grep -oP '(?<=emojibase-data@)\d+\.\d+\.\d+')" >> $GITHUB_ENV
2532
echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_ENV
2633
27-
- name: Download emoji-test data
28-
run: |
29-
curl -s -o emojify/src/test/resources/io/wax911/emojify/core/emoji-test.txt https://unicode.org/Public/emoji/${{ env.VERSION }}/emoji-test.txt
30-
31-
- name: Setup Python
32-
uses: actions/setup-python@v5
33-
with:
34+
- name: Download emoji-test data
35+
run: |
36+
curl -s -o ../../emojify/src/test/resources/io/wax911/emojify/core/emoji-test.txt https://unicode.org/Public/emoji/${{ env.VERSION }}/emoji-test.txt
37+
38+
- name: Setup Python
39+
uses: actions/setup-python@v5
40+
with:
3441
python-version: "3.10.6"
3542

36-
- name: Install Dependencies
37-
run: |
38-
pip install --upgrade pip
39-
pip install poetry
40-
poetry config virtualenvs.create true
41-
poetry install --no-root
42-
43-
- name: Run Emoji Update Script
44-
env:
45-
PYTHONUNBUFFERED: 1
46-
EMOJI_VERSION: ${{ env.VERSION }}
47-
run: |
48-
cd ${{ env.WORKING_DIR }}
49-
poetry run python emoji_generator/generator.py
50-
51-
- name: Push Changes and Create PR
52-
uses: peter-evans/create-pull-request@v7
53-
with:
43+
- name: Install Dependencies
44+
run: |
45+
pip install --upgrade pip
46+
pip install poetry==2.0.1
47+
poetry config virtualenvs.create true
48+
poetry install --no-root
49+
50+
- name: Run Emoji Update Script
51+
env:
52+
PYTHONUNBUFFERED: 1
53+
EMOJI_VERSION: ${{ env.VERSION }}
54+
run: poetry run emoji-generator
55+
56+
- name: Push Changes and Create PR
57+
uses: peter-evans/create-pull-request@v7
58+
with:
5459
commit-message: "chore(deps): update emoji.json to emojibase-data@${{ env.VERSION }}"
5560
title: "Update emoji.json to emojibase-data@${{ env.VERSION }}"
5661
body: |
@@ -60,3 +65,7 @@ jobs:
6065
branch: dependencies/emoji-base-updates
6166
author: GitHub <[email protected]>
6267
delete-branch: true
68+
token: ${{ steps.app-token.outputs.token }}
69+
labels: |
70+
dependencies
71+
feature

scripts/emoji_generator/emoji_generator/generator.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ def initialize() -> NoReturn:
3333
with open(output_path, 'w', encoding='utf-8') as stream:
3434
json.dump(emoji_output, stream, ensure_ascii=False, skipkeys=True)
3535

36-
37-
if __name__ == "__main__":
36+
def main() -> NoReturn:
37+
global __version
3838
__version = os.getenv('EMOJI_VERSION')
3939
initialize()
40+
41+
if __name__ == "__main__":
42+
main()

scripts/emoji_generator/pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ python = "3.10.6"
1010
pytest = "^8.3.4"
1111
requests = "^2.32.3"
1212

13+
[tool.poetry.scripts]
14+
emoji-generator = "emoji_generator.generator:main"
1315

1416
[build-system]
1517
requires = ["poetry-core"]

0 commit comments

Comments
 (0)