Skip to content

Commit

Permalink
Add OpenGraph definition
Browse files Browse the repository at this point in the history
  • Loading branch information
baierjan committed Jan 11, 2024
1 parent 9acde16 commit 6342e3e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
33 changes: 28 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,45 @@ runs:
- run: sudo apt-get install -y kramdown weasyprint imagemagick ghostscript
shell: bash
- name: Render Markdown from configured backlog queries
run: python backlogger/backlogger.py ${{ inputs.config }} ${{ inputs.args }}
run: |
python backlogger/backlogger.py ${{ inputs.config }} ${{ inputs.args }}
echo "BACKLOG_STATUS=$?" >> "$GITHUB_ENV"
env:
REDMINE_API_KEY: ${{ inputs.REDMINE_API_KEY }}
shell: bash
- name: Define variables
run: |
org=${{ github.repository_owner }}
repo=$(cut -f2 -d/ <<<${{ github.repository }})
[ "${{ github.event_name }}" == pull_request ] && extra="/pr-preview/pr-${{ github.event.number }}"
preview="preview_$(date +%s).png"
echo "PREVIEW_NAME=$preview" >> "$GITHUB_ENV"
echo "PREVIEW_URL=https://$org.github.io/$repo$extra/$preview" >> "$GITHUB_ENV"
if [ "${{ env.BACKLOG_STATUS }}" -eq 0 ]; then
color="#55cc33"
else
color="#cc3333"
fi
echo "STATUS_COLOR=$color" >> "$GITHUB_ENV"
shell: bash
- name: Render HTML
run: |
mkdir -p ${{ inputs.folder }}
cd ${{ inputs.folder }}
cat ../backlogger/head.html >index.html
kramdown ../index.md >>index.html
sed s@GITHUB_REPOSITORY@${{ github.repository }}@g ../backlogger/foot.html >>index.html
cat ../backlogger/head.html > index.html
kramdown ../index.md >> index.html
cat ../backlogger/foot.html >> index.html
sed -i \
-e "s@STATUS_COLOR@${{ env.STATUS_COLOR }}@g" \
-e "s@GITHUB_REPOSITORY@${{ github.repository }}@g" \
-e "s@PREVIEW_IMAGE_URL@${{ env.PREVIEW_URL }}@g" \
-e "s@WORKFLOW_NAME@${{ github.workflow }}@g" \
index.html
shell: bash
- name: Render PNG preview
run: |
cd ${{ inputs.folder }}
# Remove workaround for already fixed CVE-2018-16509
sudo sed -i '/rights="none" pattern="PDF"/d' /etc/ImageMagick-6/policy.xml
weasyprint index.html - | convert - -trim preview.png
weasyprint index.html - | convert - -trim ${{ env.PREVIEW_NAME }}
shell: bash
8 changes: 6 additions & 2 deletions head.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<html>
<html prefix="og: https://ogp.me/ns#">
<head>
<title>Backlog Status</title>
<meta charset="UTF-8">
<!-- Facebook / Slack tags -->
<meta property="og:title" content="WORKFLOW_NAME" />
<meta property="og:url" content="https://github.com/GITHUB_REPOSITORY" />
<meta property="og:image" content="PREVIEW_IMAGE_URL" />
<style>
body {
font-family: Verdana, Arial;
border-top: 5px solid #55cc33;
border-top: 5px solid STATUS_COLOR;
margin: 0px 5px 5px 5px;
}
table {
Expand Down

0 comments on commit 6342e3e

Please sign in to comment.