Skip to content

Commit e1bff0e

Browse files
committed
Wrote first version
0 parents  commit e1bff0e

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM python:3.8
2+
3+
COPY inline-css.py /inline-css.py
4+
COPY entrypoint.sh /entrypoint.sh
5+
6+
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# inline-css-action
2+
3+
Converts HTML files to use inline styling.
4+
5+
## Usage
6+
7+
```yaml
8+
- uses: ZacJW/[email protected]
9+
with:
10+
files: '["test.html", "dir/*.html"]'
11+
```
12+
13+
This example will convert `test.html` and all `.html` files in `dir/` to use inline styling.
14+
15+
## Inputs
16+
17+
### `files`
18+
19+
**Required**. A JSON list of paths to html files to convert. They will be overwritten to use inline styling. Paths may be glob patterns, in which case all matching files will be converted and overwritten.

action.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: "Inline-CSS"
2+
description: "Convert HTML files to use inline styling"
3+
inputs:
4+
files:
5+
description: "A JSON list of paths to HTML files to convert"
6+
required: true
7+
runs:
8+
using: 'docker'
9+
image: 'Dockerfile'
10+
branding:
11+
icon: file-text
12+
color: white

entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash -e
2+
3+
pip3 install premailer
4+
5+
python3 /inline-css.py

inline-css.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/python3
2+
3+
import premailer, json, os, pathlib
4+
5+
REPO_PATH = pathlib.Path(os.environ['GITHUB_WORKSPACE'])
6+
FILES_LIST = json.loads(os.environ['INPUT_FILES'])
7+
8+
pm = premailer.Premailer()
9+
10+
for file_path_str in FILES_LIST:
11+
file_path_list = REPO_PATH.glob(file_path_str)
12+
for file_path in file_path_list:
13+
with open(file_path_list, 'r') as file:
14+
html = pm.transform(file.read())
15+
with open(file_path_list, 'w') as file:
16+
file.write(html)

0 commit comments

Comments
 (0)