Skip to content

Commit 7b23cdf

Browse files
Fix UTF8 Rendering of Emojis (#5)
Co-authored-by: screenshot-action 📼 <actions@github.com>
1 parent 899f8e9 commit 7b23cdf

File tree

7 files changed

+44
-5
lines changed

7 files changed

+44
-5
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
background: linear-gradient(139deg, rgba(2,0,36,1) 0%, rgba(9,9,121,1) 56%, rgba(147,0,255,1) 100%);
3333
}
3434
customizations: |
35-
"#name": "${{ github.event.repository.name }}"
35+
"#name": "${{ github.event.repository.name }} 📷"
3636
viewportWidth: 2000
3737
viewportHeight: 800
3838

@@ -43,9 +43,9 @@ jobs:
4343
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4444
with:
4545
commit_message: "chore: update example image"
46-
commit_user_name: screenshot-action 📼
46+
commit_user_name: screenshot-action 📷
4747
commit_user_email: actions@github.com
48-
commit_author: screenshot-action 📼 <actions@github.com>
48+
commit_author: screenshot-action 📷 <actions@github.com>
4949
file_pattern: 'docs/*.png'
5050

5151
- name: Add Image to Step Summary

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ deps:
1212

1313
run:
1414
node main.js
15+
16+
# This will not work on a Mac
17+
docker/run:
18+
docker run -i --init --cap-add=SYS_ADMIN -v $(PWD):$(PWD) --workdir=$(PWD) ghcr.io/puppeteer/puppeteer:21.3.8 bash -c 'npm install --no-fund option && node main.js'

action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ inputs:
4646
waitForTimeout:
4747
description: 'Number of miliseconds to delay before taking screenshot'
4848
default: 500
49+
puppeteerImage:
50+
description: 'Docker image to run puppeteer. See https://github.com/puppeteer/puppeteer/pkgs/container/puppeteer'
51+
default: 'ghcr.io/puppeteer/puppeteer:21.7.0'
4952
outputs:
5053
file:
5154
description: "File containing the generated screenshot"
@@ -77,6 +80,7 @@ runs:
7780
7881
# Prepare inputs that should be passed to the docker container.
7982
cat<<__EOF__>docker.env
83+
LANG=C.UTF-8
8084
GITHUB_WORKSPACE=${{ github.workspace }}
8185
ACTION_PATH=${{ github.action_path }}
8286
INPUT_OUTPUT_TYPE=${{ inputs.outputType }}
@@ -105,11 +109,11 @@ runs:
105109
id: screenshot
106110
uses: tj-actions/docker-run@v2
107111
with:
108-
image: ghcr.io/puppeteer/puppeteer:21.3.8
112+
image: ${{ inputs.puppeteerImage }}
109113
name: puppeteer-chrome
110114
options: '-i --init --cap-add=SYS_ADMIN ${{ env.DOCKER_VOLUMES }} --workdir=${{github.action_path}} --env-file docker.env'
111115
args: |
112-
bash -c 'npm install --no-fund option && node main.js'
116+
bash -c './entrypoint.sh'
113117
114118
- id: context
115119
shell: bash

docs/example.png

15.7 KB
Loading

entrypoint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -ex
3+
4+
# Install Additional Fonts
5+
TWITTER_COLOR_EMOJI_VERSION="14.0.2"
6+
GOOGLE_NOTO_COLOR_EMOJI_VERSION="2.042"
7+
8+
mkdir -p ~/.fonts
9+
10+
# Solution found in https://stackoverflow.com/questions/50662388/running-headless-chrome-puppeteer-with-no-sandbox
11+
12+
# Install Noto Color Emoji
13+
curl --location --silent --show-error -o ~/.fonts/NotoColorEmoji.ttf https://github.com/googlefonts/noto-emoji/blob/v${GOOGLE_NOTO_COLOR_EMOJI_VERSION}/fonts/NotoColorEmoji.ttf?raw=true
14+
15+
# Install Twitter Emoji Font
16+
wget https://github.com/13rac1/twemoji-color-font/releases/download/v${TWITTER_COLOR_EMOJI_VERSION}/TwitterColorEmoji-SVGinOT-Linux-${TWITTER_COLOR_EMOJI_VERSION}.tar.gz
17+
tar -xzvf TwitterColorEmoji-*.tar.gz --wildcards '*.ttf'
18+
find . -type f -wholename 'TwitterColorEmoji-*/*.ttf' -exec mv {} ~/.fonts/ \;
19+
20+
# Rebuild the font cache
21+
fc-cache -f -v
22+
fc-list | grep -i emoji
23+
24+
# Install dependencies
25+
npm install --no-fund option
26+
27+
# Generate screenshot
28+
node main.js

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454

5555
"js-yaml": "^4.1.0",
5656

57+
"option": "^0.2.4",
58+
5759
"puppeteer": "^21.7.0"
5860

5961
},

test/html/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<html>
22
<head>
3+
<meta charset="UTF-8">
34
<title>Cloud Posse</title>
45
<style>
56
body {

0 commit comments

Comments
 (0)