You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Embedding code into markdown from external file.
Any language's code blocks are available.
See demo repo if you are interested in testing code within README.
How to use
In markdown, write code block as follows:
```python:tests/src/sample.py```
And, you can refer specific lines as
```python:tests/src/sample.py [4-5]
```
Then, this action referes to tests/src/sample.py and modifies markdown as (if something code is written, they are overridden):
frommathimportsqrtdefsample(x):
returnsqrt(x)
And, specific lines is refered as
defsample(x):
returnsqrt(x)
NOTE: Read file by passed path, where the top directory in your repo is working directory. If the path is wrong, this action is failed.
How to use - workflow example
Override README.md and push by action if readme is changed:
name: Embed code in READMEon:
pull_request:
branches:
- mainjobs:
embed-code:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v2with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal tokenfetch-depth: 0# otherwise, you will failed to push refs to dest reporef: refs/heads/${{ github.head_ref }}
- uses: tokusumi/markdown-embed-code@mainwith:
markdown: "README.md"token: ${{ secrets.GITHUB_TOKEN }}message: "synchronizing Readme"silent: true
Configuration
input
description
token
Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}
markdown (Optional)
Target markdown file path. (default: "README.md")
message (Optional)
Commit message for action. (default: "Embedding code into Markdown")
no_change (Optional)
Issue comment at no changed (default: "No changes on README!" )