From 32114fa751390a58131b2f6ce12b3feffabb3f4e Mon Sep 17 00:00:00 2001 From: tokusumi <41147016+tokusumi@users.noreply.github.com> Date: Wed, 5 May 2021 18:19:16 +0900 Subject: [PATCH 1/6] pin actions version --- .github/workflows/readme-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/readme-test.yml b/.github/workflows/readme-test.yml index 9613beb..e2486e1 100644 --- a/.github/workflows/readme-test.yml +++ b/.github/workflows/readme-test.yml @@ -1,4 +1,4 @@ -name: Test code and embed into README +name: "Test code and embed into README@v0.1.1" on: push: @@ -24,7 +24,7 @@ jobs: - name: Test with pytest run: pytest test_src - - uses: tokusumi/markdown-embed-code@main + - uses: tokusumi/markdown-embed-code@0.1.1 with: markdown: "README.md" From a572f993c1b1a3c5af4f8619c1386bb2599482e1 Mon Sep 17 00:00:00 2001 From: tokusumi <41147016+tokusumi@users.noreply.github.com> Date: Wed, 5 May 2021 18:23:53 +0900 Subject: [PATCH 2/6] Update readme-test.yml --- .github/workflows/readme-test.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/readme-test.yml b/.github/workflows/readme-test.yml index e2486e1..c8908d2 100644 --- a/.github/workflows/readme-test.yml +++ b/.github/workflows/readme-test.yml @@ -1,12 +1,8 @@ name: "Test code and embed into README@v0.1.1" on: - push: - branches: - - main - pull_request: - branches: - - main + workflow_dispatch: + jobs: readme-test: runs-on: ubuntu-latest From 38c9223db4dbd70d09985305eb82b0c21db179f4 Mon Sep 17 00:00:00 2001 From: tokusumi <41147016+tokusumi@users.noreply.github.com> Date: Wed, 5 May 2021 18:51:12 +0900 Subject: [PATCH 3/6] Update readme-test.yml --- .github/workflows/readme-test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/readme-test.yml b/.github/workflows/readme-test.yml index c8908d2..26346d3 100644 --- a/.github/workflows/readme-test.yml +++ b/.github/workflows/readme-test.yml @@ -1,7 +1,6 @@ -name: "Test code and embed into README@v0.1.1" +name: Test code and embed into README -on: - workflow_dispatch: +on: [workflow_dispatch] jobs: readme-test: From afbf935072218f02806cd17a07c35c92339f2aa1 Mon Sep 17 00:00:00 2001 From: tokusumi <41147016+tokusumi@users.noreply.github.com> Date: Wed, 5 May 2021 19:04:20 +0900 Subject: [PATCH 4/6] re-enable action --- .github/workflows/readme-test.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/readme-test.yml b/.github/workflows/readme-test.yml index 26346d3..512873e 100644 --- a/.github/workflows/readme-test.yml +++ b/.github/workflows/readme-test.yml @@ -1,7 +1,12 @@ name: Test code and embed into README -on: [workflow_dispatch] - +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: readme-test: runs-on: ubuntu-latest From eb01bc984a8ab89741226b3b185e70b70ac2c34f Mon Sep 17 00:00:00 2001 From: tokusumi <41147016+tokusumi@users.noreply.github.com> Date: Wed, 5 May 2021 19:08:11 +0900 Subject: [PATCH 5/6] fix action version --- .github/workflows/readme-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/readme-test.yml b/.github/workflows/readme-test.yml index 512873e..0340a3a 100644 --- a/.github/workflows/readme-test.yml +++ b/.github/workflows/readme-test.yml @@ -24,7 +24,7 @@ jobs: - name: Test with pytest run: pytest test_src - - uses: tokusumi/markdown-embed-code@0.1.1 + - uses: tokusumi/markdown-embed-code@v0.1.1 with: markdown: "README.md" From faded47ad0e6c0a619652e94360e79225ca9cc5a Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 5 May 2021 10:08:42 +0000 Subject: [PATCH 6/6] Embedding code into Markdown --- README.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/README.md b/README.md index e2cf996..fe9dc02 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,18 @@ ![Test code and embed into README](https://github.com/tokusumi/readme-code-testing/workflows/Test%20code%20and%20embed%20into%20README/badge.svg) - This repo demonstrates [Markdown Embed Code From File](https://github.com/marketplace/actions/markdown-embed-code-from-file) (GitHub Action). - This would helps testing for your code within readme (actually for markdown). - You could put code in external file and test them, as same as ordinary testing your code. You don't need copy & paste code and feel anxisous about compatibility anymore. - ## Mark your code for embedding This action could inspect your code, if you add a file path in code block as "\`\`\`lang:external/file/path.py\`\`\`". - The following code block has a file path `src/helloworld.py`: - ```python:src/helloworld.py def hello(): return "world" @@ -27,19 +21,16 @@ def hello(): See with [src/helloworld.py]() as: - * Synchronized code. * Highlighting code in readme. * Not affected code rendering. And notice that nothing to do re-embedding new/modified code. This action overrides code if you change code in external file. - ### Multiple use You might add one file path (ex. [src/mul.py]()) for multiple code blocks: - ```py:src/mul.py from math import pow @@ -49,7 +40,6 @@ def multiple(x): It works!: - ```py:src/mul.py from math import pow @@ -59,23 +49,18 @@ def multiple(x): However, the other is not available. - ### Non-existent file Notice that this action goes to "fail" if a file you add does not exist. - ## Multilingual This action could work for any programming "language". - Ideally you could write as "\`\`\`lang:external/file/path.py\`\`\`", but actually this action does not inspect "lang", just read path and copy&paste strings into target code block in markdown. - So, missing "lang" is available: - ```:src/helloworld.sh #!/bin/bash