Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support installation of custom google font used inside diagrams #54

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/plantuml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: generate and commit diagrams
uses: abekoh/commit-plantuml-action@1.0.3
uses: zaphiro-technologies/commit-plantuml-action@install-google-fonts
with:
botEmail: ${{ secrets.BOT_EMAIL }}
botGithubToken: ${{ secrets.GITHUB_TOKEN }}
enableReviewComment: true
installGoogleFont: Barlow:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM ubuntu:latest
FROM ubuntu:22.04


ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update
RUN apt-get install -y fonts-ipafont graphviz wget openjdk-8-jre git curl
RUN wget -P / --content-disposition https://sourceforge.net/projects/plantuml/files/plantuml.jar/download
RUN apt-get install -y fonts-ipafont graphviz openjdk-8-jre git curl
RUN curl -L https://github.com/plantuml/plantuml/releases/latest/download/plantuml.jar > /plantuml.jar

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
botEmail: ${{ secrets.BOT_EMAIL }}
botGithubToken: ${{ secrets.GITHUB_TOKEN }}
enableReviewComment: true
installGoogleFont: Barlow:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i
```

You must set `actions/checkout` before this step, to get source codes.
Expand All @@ -41,3 +42,11 @@ To add review comment. Use default [`secrets.GITHUB_TOKEN`](https://docs.github.
required: false, default: false

If set `true`, diff png files' information are submitted to pull request.

### installGoogleFont

required: false

If set, the value will be use to download and install a font family from
[google](https://fonts.google.com/). To be used in combination with `skinparam
defaultFontName` and other FontName skin settings for plantuml.
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ inputs:
enableReviewComment:
description: "whether post review comment or not"
required: false
default: false
default: "false"
installGoogleFont:
description: "Google Font family to be installed"
required: false
runs:
using: "docker"
image: "Dockerfile"
23 changes: 19 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ if [[ "${INPUT_ENABLEREVIEWCOMMENT}" = "true" && ! "${INPUT_BOTGITHUBTOKEN}" ]];
echo "ERROR: Please set inputs.botGithubToken"
exit 1
fi
if [ -z "$INPUT_INSTALLGOOGLEFONT" ]; then
echo "No font family defined"
else
echo "Installing $INPUT_INSTALLGOOGLEFONT"
curl -L https://raw.githubusercontent.com/neverpanic/google-font-download/master/google-font-download > google-font-download
chmod +x google-font-download
./google-font-download -f ttf --url="https://fonts.google.com/?selection.family=$INPUT_INSTALLGOOGLEFONT"
mkdir /usr/share/fonts/googlefonts
mv *.ttf /usr/share/fonts/googlefonts
rm *.css
rm google-font-download
fc-cache -fv
fi

# generate
git config --global --add safe.directory ${GITHUB_WORKSPACE}
Expand All @@ -26,22 +39,23 @@ done

# commit
if [[ ! $(git status --porcelain) ]]; then
echo "No changes to commit"
exit 0
fi
git config user.name "${GITHUB_ACTOR}"
git config user.email "${INPUT_BOTEMAIL}"
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${INPUT_BOTEMAIL}"
git checkout ${GITHUB_HEAD_REF}
git add .
git commit -m "add generated diagrams"
git push origin HEAD:${GITHUB_HEAD_REF}
echo "comitted png files"

# add review comment
if [[ "${INPUT_ENABLEREVIEWCOMMENT}" != "true" ]]; then
git push origin HEAD:${GITHUB_HEAD_REF}
exit 0
fi
git fetch
GITHUB_SHA_AFTER=$(git rev-parse origin/${GITHUB_HEAD_REF})
GITHUB_SHA_AFTER=$(git rev-parse HEAD)
DIFF_FILES=`git diff ${GITHUB_SHA} ${GITHUB_SHA_AFTER} --name-only | grep ".png"`
echo $DIFF_FILES
BODY="## Diagrams changed\n"
Expand Down Expand Up @@ -71,3 +85,4 @@ curl -X POST \
-d "{\"event\": \"COMMENT\", \"body\": \"${BODY}\"}" \
"${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${PULL_NUM}/reviews"
echo "added review comments"
git push origin HEAD:${GITHUB_HEAD_REF}
Binary file modified sample/backlog-item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sample/backlog-item.puml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@startuml
skin rose
skinparam defaultFontName Barlow

object BacklogItem {
<<aggregate root>>
Expand Down