ソースを参照

【维护】创建 Deploy markdown.html 动作

- 新增 action.yml 文件,定义压缩 markdown.html 并部署到目标目录的 GitHub Actions
- 包含 Setup Rust、Build project、Generate minimized HTML 和 Deploy minimized file 等步骤
- 设置动作图标为 book-open,颜色为 green
PJ568 1 年間 前
親
コミット
3849917f09
3 ファイル変更、57 行追加、0 行削除
  1. 11 0
      README.md
  2. 11 0
      README_EN.md
  3. 35 0
      action.yml

+ 11 - 0
README.md

@@ -15,9 +15,20 @@
 
 ## 使用方法
 
+### 手动部署
+
 1. 下载并重命名本仓库的 `index.html` 文件到你的网站根目录或任何其他目录中;
 2. 当下载并重命名后的 `index.html` 被访问时,将自动渲染同目录下的 `index.md`,如果 `index.md` 不存在,则渲染 `README.md`。
 
+### Github Actions
+
+```yaml
+- name: Deploy markdown.html
+  uses: PJ-568/[email protected]
+  with:
+    target-dir: '.'
+```
+
 ## 其他说明
 
 `本项目使用的开源项目允许修改,但请保留原作者信息。确需去除,请联系作者,以免失去技术支持。`详情请参照许可证。

+ 11 - 0
README_EN.md

@@ -15,9 +15,20 @@ This project aims to provide a low-dependency, simple deployment solution for re
 
 ## Usage
 
+### Manual Deployment
+
 1. Download and rename the `index.html` file from this repository and place to your website's root directory or any other directory;
 2. When the html file is accessed, it will automatically render the `index.md` in the same directory. If `index.md` does not exist, it will render `README.md`.
 
+### Github Actions
+
+```yaml
+- name: Deploy markdown.html
+  uses: PJ-568/[email protected]
+  with:
+    target-dir: '.'
+```
+
 ## Additional Notes
 
 `The open-source projects used in this project allow modifications, but please retain the original author information. If removal is necessary, please contact the author to avoid losing technical support.` For more details, refer to the license.

+ 35 - 0
action.yml

@@ -0,0 +1,35 @@
+name: Deploy markdown.html
+description: Compress markdown.html and deploy to target directory
+author: 'PJ568'
+
+inputs:
+  target-dir:
+    description: Directory to deploy the minimized HTML file
+    default: "."
+    required: true
+
+runs:
+  using: "composite"
+  steps:
+    - name: Setup Rust
+      uses: MatteoH2O1999/setup-rust@v1
+
+    - name: Build project
+      run: cargo build --release
+      shell: bash
+      working-directory: ${{ github.action_path }}
+
+    - name: Generate minimized HTML
+      run: cargo run --release -- ${{ github.action_path }}/index.html ${{ github.action_path }}/index.min.html
+      shell: bash
+      working-directory: ${{ github.action_path }}
+
+    - name: Deploy minimized file
+      run: |
+        mkdir -p "${{ inputs.target-dir }}"
+        mv ${{ github.action_path }}/index.min.html "${{ inputs.target-dir }}/index.html"
+      shell: bash
+
+branding:
+  icon: 'book-open'
+  color: 'green'