• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

neenjaw/compile-mermaid-markdown-action: A github action to compile mermaid mark ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

neenjaw/compile-mermaid-markdown-action

开源软件地址(OpenSource Url):

https://github.com/neenjaw/compile-mermaid-markdown-action

开源编程语言(OpenSource Language):

Shell 82.0%

开源软件介绍(OpenSource Introduction):

NOTICE: Github has publicly added mermaid support to their roadmap to support (ref). When it is released, this action will be archived and removed from the market place.

compile-mermaid-markdown-action (beta)

Purpose

Markdown is a common way to present useful information with rich formatting from a simple human readable syntax. Especially useful is being able to highlight code blocks.

Mermaid-JS takes this philosophy and applies it to graphs! Taking simple human-readable syntax and returning rich graphs.

Github markdown does not automatically render mermaid to the browser, so this action does that for you so you can just worry about the markdown and not the toolchain.

Contributing

Looking for suggestions/help in improving this action. If there is a feature you want, or you encounter a bug, please let me know and we can work together to improve it.

How to use

The idea is that this action is to be used within a workflow, not as a standalone action at this time.

Some environment variables can be set to tune the compilation:

  • OUTPUT_FILE_TYPE can be used to define the output file type, if you don't specify it it will default to png. You can override it to svg or pdf.
  • MMDC_EXTRA_ARGS can be used to add extra command line arguments to the mmdc command line generating diagrams. Do not include -i, -o and -p arguments as they are already handled outside of this variable.

Sample workflow with automated PR

(adapted from my example repo:

name: 'Compile Mermaid'

on:
  push:
    paths:
      - '**/*.mermaid'
      - '**/*.mmd'
      - '**/*.md'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 2
      - name: get changed files
        id: getfile
        run: |
          echo "::set-output name=files::$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -e '.*\.md$' -e '.*\.mmd$' -e '.*\.mermaid$' | xargs)"

      - name: mermaid files changed
        run: |
          echo ${{ steps.getfile.outputs.files }}

      - name: compile mermaid
        uses: neenjaw/[email protected]
        with:
          files: ${{ steps.getfile.outputs.files }}
          output: 'output'
        env:
          HIDE_CODEBLOCKS: 1
          ABSOLUTE_IMAGE_LINKS: 1
          OUTPUT_FILE_TYPE: "svg"

      - name: show changes
        run: |
          git status

      - name: Create Pull Request
        id: cpr
        uses: peter-evans/create-pull-request@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: Add compiled mermaid
          title: '[MMDC] New mermaid files compiled'
          body: |
            - Auto-generated by [create-pull-request][1]

            [1]: https://github.com/peter-evans/create-pull-request
          labels: report, automated pr
          assignees: ${{ github.actor }}
          reviewers: ${{ github.actor }}
      - name: Check outputs
        run: |
          echo "Pull Request Number - ${{ env.PULL_REQUEST_NUMBER }}"
          echo "Pull Request Number - ${{ steps.cpr.outputs.pr_number }}"

Sample workflow with changes pushed

name: 'Compile Mermaid in Markdown'

on:
  push:
    paths:
      - '**/*.md'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 2

      - name: get changed files
        id: getfile
        run: |
          echo "::set-output name=files::$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -e '.*\.md$' | xargs)"

      - name: md files changed
        run: |
          echo ${{ steps.getfile.outputs.files }}

      - name: compile mermaid
        uses: neenjaw/[email protected]
        with:
          files: ${{ steps.getfile.outputs.files }}
          output: '.resources'
        env:
          HIDE_CODEBLOCKS: 1
          ABSOLUTE_IMAGE_LINKS: 1
          OUTPUT_FILE_TYPE: "svg"

      - name: show changes
        run: |
          git status

      - name: Commit files
        run: |
          git config --local user.email "[email protected]"
          git config --local user.name "GitHub Action"
          git commit -m "Add changes" -a

      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap