Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/austenstone/markdown-interpolation-action
An action for text interpolation that lets you incorporate dynamic string values into your markdown files.
https://github.com/austenstone/markdown-interpolation-action
actions interpolation markdown
Last synced: 2 months ago
JSON representation
An action for text interpolation that lets you incorporate dynamic string values into your markdown files.
- Host: GitHub
- URL: https://github.com/austenstone/markdown-interpolation-action
- Owner: austenstone
- Created: 2022-03-10T22:49:28.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-19T13:37:23.000Z (about 1 year ago)
- Last Synced: 2024-10-10T21:18:14.086Z (3 months ago)
- Topics: actions, interpolation, markdown
- Language: TypeScript
- Homepage:
- Size: 14.1 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Markdown Interpolation Action
This action interpolates markdown with variables.
See [Markdown Interpolation](https://github.com/austenstone/markdown-interpolation#writing) to understand how to use the interpolation syntax.
## EXAMPLE 1
Create a workflow (eg: `.github/workflows/run.yml`). See [Creating a Workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).### [Example 1 Workflow](.github/workflows/example1.yml)
```yml
name: Example 1
on:
schedule:
- cron: "* * * * *"
jobs:
write-time:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
id: values
with:
script: |
return {
TIME: new Date().toLocaleString('en-US', { timeZone: 'America/New_York', timeZoneName: 'short' }),
};
- uses: austenstone/markdown-interpolation-action@main
with:
values: ${{ steps.values.outputs.result }}
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_author: github-actions[bot]```
### Example 1 README
```md
##### Last Updated: 10/5/2023, 8:38:17 PM (EST)
```### Example 1 Result (LIVE)
##### Last Updated: 10/5/2023, 8:38:17 PM (EST)## EXAMPLE 2
An example to manually update a message on the README.md file.
### [Example 2 Workflow](.github/workflows/example2.yml)
```yml
name: Example 2
on:
workflow_dispatch:
inputs:
message:
description: "A message to show in the README.md file"
required: true
default: "Hello World!"jobs:
write-message:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
id: values
env:
MESSAGE: ${{ github.event.inputs.message }}
AUTHOR: ${{ github.actor }}
with:
script: |
return {
MESSAGE: process.env.MESSAGE,
AUTHOR: process.env.AUTHOR,
};
- uses: austenstone/markdown-interpolation-action@main
with:
values: ${{ steps.values.outputs.result }}
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_author: github-actions[bot]```
### Example 2 README
```md
@austenstone says Hello World!
```### Example 2 Result (LIVE)
@austenstone says Hello World!## EXAMPLE 3
This example is actually upating the README.md examples themselves 🤯
These example `yml` scripts in the README are generated automatically when the files change.### [Example 3 Workflow](.github/workflows/example3.yml)
```yml
name: Example 3
on:
push:
branches:
- "main"
paths:
- ".github/workflows/**.yml"jobs:
write-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
id: values
with:
script: |
const fs = require('fs');
const examples = ['example1', 'example2', 'example3', 'example4'];
const exampleContent = {};
examples.forEach((example) => {
let content = fs.readFileSync(`.github/workflows/${example}.yml`).toString();
content = content.replace('uses: austenstone/markdown-interpolation-action@main', 'uses: austenstone/markdown-interpolation-action@main');
content = content.replace(/.*- uses: actions\/checkout@v[0-9]+\n/g, '')
exampleContent[example.toUpperCase()] = '\n```yml\n' + content + '\n```\n';
});
return exampleContent;
- uses: ./
with:
values: ${{ steps.values.outputs.result }}
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_author: github-actions[bot]```
### Example 3 Result (LIVE)
yaml code snippets [Example 1](#example-1-workflow), [Example 2](#example-2-workflow), [Example 3](#example-3-workflow), [Example 4](#example-4-workflow).## EXAMPLE 4
Examine the event context of the last run.
⚠️ This is just an example and shouldn't be used on a public repository.### [Example 4 Workflow](.github/workflows/example4.yml)
```yml
name: Example 4
on:
issues:
types:
- opened
- editedjobs:
write-last-issue:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
id: values
with:
script: |
return {
TITLE: context.payload.issue.title,
BODY: context.payload.issue.body,
NUMBER: '#' + context.payload.issue.number,
};
- uses: austenstone/markdown-interpolation-action@main
with:
values: ${{ steps.values.outputs.result }}
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_author: github-actions[bot]```
### Example 4 Result (LIVE)
#### Example 4 Test #1
This is a test for Example 4.## Inputs
| Name | Description | Default |
| --- | - | - |
| **values** | JSON values to interpolate in markdown. | N/A |
| files-regex | File name match as regex. | README.md |
| files-regex-flags | Regex flags for files-regex. | gi |## Outputs
| Name | Description | Default |
| --- | - | - |
| **values** | JSON values read. (last values) | {} |