-
Notifications
You must be signed in to change notification settings - Fork 4
35 lines (33 loc) · 1.06 KB
/
emoji.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Emoji
on: [ push, pull_request ]
env:
PIP_DISABLE_PIP_VERSION_CHECK: yes
jobs:
check-emoji:
name: Check for emoji in commit message
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Fetch PR commit
if: github.event_name == 'pull_request'
run: git fetch origin ${{ github.event.pull_request.head.sha }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install required library
run: pip install "emoji==2.*"
- name: Run the check
shell: python
run: |
import emoji, os
if "${{ github.event_name }}".startswith("pull_request"):
commit = "${{ github.event.pull_request.head.sha }}"
else:
commit = "${{ github.sha }}"
commit_message = os.popen(f"git show -s --format=%B {commit}").read()
if not emoji.emoji_count(commit_message):
exit("No Emoji found. 👎")