As a power user, automate the updating of markdown text with content obtained from other actions in the workflow, as well as a Go module that can update markdown text
A Go module that updates markdown text and is integrated as a GitHub Action.
Parameter | Workflow default | Description | Required | Possible values |
---|---|---|---|---|
readme_path | ./README.md | Path of the markdown file | No | File path relative to the root directory of the GitHub repo |
marker_text | null | Marker text to replace in markdown file | Yes | Example markers to be added in the markdown:<!-- marker_text_START --><!-- marker_text_END --> |
markdown_text | null | Markdown text that needs to be updated | Yes | Any markdown compatible text |
table | false | Markdown text is a table | No | true, false |
table_options | null | Alignment for the table | No | align-Alignment, col-Column-align-Alignment, col-Column-w-Min-width |
Alignment: left, right, center
Column: Column number of the table (starts with 0
)
Min-width: Minimum width of a column (in other words, minimum number of hyphens (-
) in the delimiter row)
- Make sure to change the following in your GitHub repo settings:
Actions
>General
>Workflow permissions
> ChooseRead and write permissions
> CheckAllow GitHub Actions to create and approve pull requests
>Save
. - Other parameters
commit_user
,commit_email
,commit_message
andconfirm_and_push
related to action workflow are optional. - If
confirm_and_push
is "false" committer detalis can be accessed viaoutputs.commit_user
,outputs.commit_email
&outputs.commit_message
for further usage in the workflow. - The syntax mostly revolves around GitHub Flavored Markdown parser.
- The
table
parameter is optional asmarkdown_text
supports table markdown syntax by default but this parameter can be used as a simple alternative or any special use case. Iftable
is "true":- It uses github.com/willabides/mdtable module.
markdown_text
contents should follow these conditions:- Table row contents are seperated with ";" delimiter. First element will make up the table header.
- For each element of table rows, table column contents are seperated with "," delimiter.
table_options
can be used only iftable
is "true".- Description of options/values:
align-
: This option aligns the whole table according to the alignment set.col-
: This option sets properties of any particular column based on the column number.
- Order of preference of the alignment options:
col-
>align-
- Description of options/values:
- The markdown file must contain start marker
<!-- EXAMPLE_MARKER_START -->
and end marker<!-- EXAMPLE_MARKER_END -->
where "EXAMPLE_MARKER" is the input ofmarker_text
parameter. Note that the_START
and_END
part is important.
Check the example workflow here.
See CONTRIBUTING.md for more details.
This project uses few of the open-source Go modules, without which it would not have been possible. I extend my gratitude to the developers and maintainers of these modules for their valuable contributions to the open-source community:
- github.com/willabides/mdtable - Generates markdown tables from string slices.
- github.com/mattn/go-runewidth - Provides functions to get fixed width of the character or string.
- github.com/rivo/uniseg - Implements Unicode Text Segmentation, Word Wrapping, and String Width Calculation.
This project is licensed under GPL-3.0.
Copyright © 2024, Naveen Prashanth. All Rights Reserved.