This is a GitHub Action that updates the contents of an article on TMC's website (article) with the contents of a file in the caller's repository.
Here are the Linux packages required from the caller to use this GitHub Action.
On Debian and Ubuntu systems, you most likely will only need to install jq and gawk separately in your caller repository's workflow like the below step.
- name: Install dependencies for TMC Article Update Action.
run: sudo apt update && sudo apt install -y jq gawk
shell: bashHere are a list of inputs you will need to pass to the action from your repository (the caller).
| Name | Default | Description |
|---|---|---|
verbose |
1 |
What verbose output to print in the workflow (0 = None. 1 = Basic updates which includes post ID. 2 = everything from value 1, but with response output from the TMC API via cURL. 3 = Escaped strings and more verbose cURL output) |
env_file |
.tau/.env |
The environmental file to load. Look at Environment Configuration for more details! |
file |
README.md |
The local Markdown file whose contents will replace the TMC article. |
tmc_api_url |
N/A | The TMC API URL (e.g., https://moddingcommunity.com/api). |
tmc_api_key |
N/A | The TMC API key retrieved from custom integration. |
tmc_id |
N/A | The TMC article ID to update. |
NOTE - The only optional inputs are verbose, env_file, and file.
It is strongly recommended you use repository secrets to safely pass your TMC API information to the action.
To add secrets, go to your repository's Settings page -> Security and variables -> Actions -> Repository secrets -> New repository secret.
The script that processes and updates the final Markdown contents before updating the TMC article loads an environment file if the path to the value of env_file exists (default is .tau/.env).
Here is the configuration for that file. The following general variables are available to set inside of the environmental file if specified through the env_file input setting.
| Name | Default | Description |
|---|---|---|
LINES_SKIP |
N/A | A list of line numbers to skip in the final Markdown output to the TMC article separated by commas (if multiple lines). |
DEL_MULTIPLE_HYPHENS_IN_LINKS |
0 |
If set to 1, will replace multiple hyphens with just a single -. |
This action supports mapping header link URLs if needed.
For example, say you have the following header links.
* [Something 1](#something-1)
* [Something 2](#something-2)However, on the TMC article, the header link for Something 1 is #something-3. You can use this feature to ensure the TMC article contains this.
* [Something 1](#something-3)
* [Something 2](#something-2)The prefix for each link environmental variable is LINK_. When setting the environmental variable, you'll need to convert all letters to upper-case and replace - with _.
For example:
#something-1=>LINK_SOMETHING_2#something--2=>LINK_SOMETHING__3
Here's an example of setting environmental variables that maps the two links above.
LINK_SOMETHING_1="something-2"
LINK_SOMETHING__2="something--3"
Here's a full workflow example on the caller's side.
name: Update TMC Article
on:
push:
branches: [ main ]
jobs:
update-tmc-article:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies for TMC Article Update Action
run: sudo apt update && sudo apt install -y jq gawk
shell: bash
- uses: gamemann/tmc-api-article@v1.0.0
with:
file: CONTENTS.md
tmc_api_url: ${{ secrets.TMC_API_URL }}
tmc_api_key: ${{ secrets.TMC_API_KEY }}
tmc_article_id: ${{ secrets.TMC_ARTICLE_ID }}Then inside of the repository are repository secrets set using the steps mentioned earlier.
I create a lot of guides on my modding community b log with a GitHub repository in its organization since both GitHub and TMC support the Markdown syntax.
This action allows me to update the guide through GitHub then the workflow automatically updates the contents of the article.
Here are some guides from my modding community using this neat GitHub Action!