-
Notifications
You must be signed in to change notification settings - Fork 7
/
action.yaml
111 lines (109 loc) · 3.7 KB
/
action.yaml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
name: 'Backlog Limits Checker'
description: 'Produce a static webpage with an overview of your backlog'
branding:
icon: 'activity'
color: 'orange'
inputs:
config:
description: The configuration file
required: false
default: 'queries.yaml'
args:
description: Additional arguments to the script
required: false
default: '--exit-code'
folder:
description: Output folder for HTML files
required: false
default: 'gh-pages'
state:
description: Output folder for state keeping
required: false
default: 'state'
redmine_api_key:
description: The Redmine API key
required: true
webhook_url:
description: URL to a webhook to post a notification (e.g. for slack)
required: false
default: ''
runs:
using: composite
steps:
- uses: actions/checkout@v4
with:
repository: openSUSE/backlogger
path: backlogger
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r backlogger/requirements.txt
shell: bash
- run: sudo apt-get update && sudo apt-get install -y kramdown weasyprint imagemagick ghostscript
shell: bash
- name: Get previous published state
uses: actions/checkout@v4
with:
ref: ${{ inputs.folder }}
path: ${{ inputs.state }}
# https://github.com/actions/checkout#fetch-only-a-single-file
sparse-checkout: |
state.json
sparse-checkout-cone-mode: false
- run: rm -rf ${{ inputs.state }}/.git
shell: bash
- name: Render Markdown from configured backlog queries
run: |
python backlogger/backlogger.py ${{ inputs.config }} ${{ inputs.args }}
echo "BACKLOG_STATUS=$?" >> "$GITHUB_ENV"
env:
REDMINE_API_KEY: ${{ inputs.REDMINE_API_KEY }}
STATE_FOLDER: ${{ inputs.state }}
WEBHOOK_URL: ${{ inputs.webhook_url }}
shell: bash
continue-on-error: true
- 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_date="$(date +%s)"
preview="preview.png"
echo "PREVIEW_NAME=$preview" >> "$GITHUB_ENV"
echo "PREVIEW_URL=https://$org.github.io/$repo$extra/$preview?v=$preview_date" >> "$GITHUB_ENV"
if [ "${{ env.BACKLOG_STATUS }}" == 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
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 ${{ env.PREVIEW_NAME }}
shell: bash
- name: Publish state json
run: cp state.json ${{ inputs.folder }}/
shell: bash