-
Notifications
You must be signed in to change notification settings - Fork 320
63 lines (55 loc) · 1.8 KB
/
main.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
63
name: Extract HTML Info
on:
push:
branches: [ gh-pages ]
paths:
- '**.html'
jobs:
extract-info:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Check Commit Message
id: check_msg
run: |
commit_msg=$(git log --format=%B -n 1)
if [[ "$commit_msg" == "Sync files from source repo" ]]; then
echo "::set-output name=run_job::true"
else
echo "::set-output name=run_job::false"
fi
- name: Set up Python
uses: actions/setup-python@v2
if: steps.check_msg.outputs.run_job == 'true'
with:
python-version: '3.x'
- name: Install Dependencies
if: steps.check_msg.outputs.run_job == 'true'
run: |
python -m pip install --upgrade pip
pip install beautifulsoup4
- name: Get Changed HTML Files
id: getfile
if: steps.check_msg.outputs.run_job == 'true'
run: |
changed_files=$(git diff --name-only HEAD~1 HEAD | grep '\.html')
echo "::set-output name=file::$changed_files"
- name: Extract Info from HTML Files
if: steps.check_msg.outputs.run_job == 'true'
run: |
for file in ${{ steps.getfile.outputs.file }}
do
python extract_info.py $file
done
- name: Commit and Push New File
if: steps.check_msg.outputs.run_job == 'true'
run: |
git config user.name "GitHub Action"
git config user.email "[email protected]"
git add .
git commit -m "Add new HTML file" || echo "No changes to commit"
git push -f origin gh-pages