-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (55 loc) · 1.56 KB
/
publish.yml
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
name: Publish
on:
pull_request:
branches: [main]
paths:
- "blogs/**"
- "!README.md"
push:
branches: [main]
paths:
- "blogs/**"
- "!README.md"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
env:
API_KEY: ${{ secrets.API_KEY }}
steps:
- name: Get Repo
uses: actions/checkout@v3
- name: Get Changed Files
id: files
uses: Ana06/get-changed-files@v2.2.0
with:
format: "csv"
filter: "*.md"
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Dependencies
run: |
pip install pip -U
if [ -f requirements.txt ]; then
pip install -r requirements.txt
fi
- name: Publish Article
run: |
files="${{ steps.files.outputs.added_modified }}"
mapfile -d ',' -t added_modified_files < <(printf '%s,' '${{ steps.files.outputs.added_modified }}')
if [[ ${#files} -gt 0 ]]; then
echo "Publishing articles to DEV.to 🎉"
for added_modified_file in "${added_modified_files[@]}"; do
echo "Do something with this ${added_modified_file}."
python script/publish.py ${added_modified_file}
done
else
echo "No posts to publish"
fi
- name: Auto Commit Message
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[auto] Article is published 🚀"