-
Notifications
You must be signed in to change notification settings - Fork 1
85 lines (74 loc) · 2.9 KB
/
Copy pathgh-pages.yml
File metadata and controls
85 lines (74 loc) · 2.9 KB
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
# GitHub workflow for generating test files and deploying to gh-pages
name: Generate Test Files and Deploy to gh-pages
# Controls when the action will run.
on:
# Triggers the workflow on push to main branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build-and-deploy"
build-and-deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions:
contents: write
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Sets up python
- uses: actions/setup-python@v2
with:
python-version: 3.14
# Install dependencies
- name: "Installs dependencies"
run: |
python3 -m pip install --upgrade pip
python3 -m pip install setuptools wheel twine
# Build and install the project
- name: "Builds and installs the project"
run: |
python3 setup.py sdist bdist_wheel
python3 -m pip install -e . --break-system-packages
# Generate test files
- name: "Generates test files"
run: |
# Check if there are any EPUB files in examples directory
if [ -z "$(ls -A examples/*.epub 2>/dev/null)" ]; then
echo "No EPUB files found in examples directory"
exit 1
fi
# Generate test files
epub-browser ./examples --no-server --output-dir ./test --keep-files
# Deploy to gh-pages
- name: "Deploys to gh-pages"
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./test
publish_branch: gh-pages
force_orphan: true
commit_message: "Update test files"
# Send Feishu notification
- name: "Send Feishu notification"
if: always()
run: |
STATUS="${{ job.status }}"
if [ "$STATUS" == "success" ]; then
STATUS_TEXT="成功"
elif [ "$STATUS" == "failure" ]; then
STATUS_TEXT="失败"
else
STATUS_TEXT="取消"
fi
curl -X POST "${{ secrets.FEISHU_WEBHOOK }}" \
-H "Content-Type: application/json" \
-d '{
"msg_type": "text",
"content": {
"text": "GitHub workflow 通知:\n- 工作流:Generate Test Files and Deploy to gh-pages\n- 状态:'"$STATUS_TEXT"'\n- 触发事件:'"${{ github.event_name }}"',\n- 提交:'"${{ github.sha }}"',\n- 分支:'"${{ github.ref }}"',\n- 仓库:'"${{ github.repository }}"''
}
}'