Skip to content

Commit df1cc86

Browse files
authored
Use atmos to generate readme (#23)
* Use atmos to generate readme * Update action.yml * Update action.yml * Update action.yml * Update action.yml * Update README.yaml * Parameterize atmos docs generate target * Parameterize atmos docs generate target
1 parent 5729f5e commit df1cc86

File tree

2 files changed

+55
-14
lines changed

2 files changed

+55
-14
lines changed

README.yaml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,39 @@ usage: |-
113113
banner_enabled: true
114114
readme_enabled: true
115115
```
116+
117+
### Migrating from `v0` to `v1`
118+
119+
`v1` use [atmos](https://atmos.tools/cli/commands/docs/generate) instead of [build-harness](https://github.com/cloudposse/build-harness).
120+
You can drop `Makefile` if you use it only for readme generation.
121+
To support atmos reaadme generation, you must create `atmos.yaml` config.
122+
The configuration depends on your repo - please follow this [documentation](https://atmos.tools/cli/commands/docs/generate)
123+
124+
Example:
125+
126+
```yaml filename="atmos.yaml"
127+
docs:
128+
generate:
129+
readme:
130+
base-dir: .
131+
input:
132+
- "./README.yaml"
133+
template: "https://.../README.md.gotmpl"
134+
output: "./README.md"
135+
terraform:
136+
source: src/
137+
enabled: false
138+
format: "markdown"
139+
show_providers: false
140+
show_inputs: true
141+
show_outputs: true
142+
sort_by: "name"
143+
hide_empty: false
144+
indent_level: 2
145+
```
146+
116147
include:
117148
- "docs/github-action.md"
118149

119150
# Contributors to this project
120-
contributors: []
151+
contributors: []

action.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ inputs:
3838
required: false
3939
default: 'true'
4040

41+
target:
42+
description: "Configuration name"
43+
required: true
44+
default: 'readme'
45+
4146
validate_readme:
4247
required: false
4348
default: 'true'
@@ -92,6 +97,11 @@ inputs:
9297
no-release
9398
readme
9499
100+
atmos-version:
101+
description: The version of atmos to install
102+
required: false
103+
default: '>= 1.175.0'
104+
95105
outputs:
96106
banner_file:
97107
description: "Generated banner file path (if banner_enabled: true)"
@@ -201,14 +211,12 @@ runs:
201211
viewportHeight: 320
202212
omitBackground: true
203213

204-
- name: Initialize Makefile with `build-harness` support
205-
if: inputs.readme_enabled == 'true'
206-
shell: bash
207-
run: |
208-
if [[ ! -f Makefile ]]; then
209-
echo '-include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness)' > Makefile
210-
fi
211-
make init
214+
- name: Install Atmos
215+
uses: cloudposse/github-action-setup-atmos@v2
216+
with:
217+
atmos-version: ${{ inputs.atmos-version }}
218+
token: ${{ inputs.token }}
219+
install-wrapper: false
212220

213221
- name: Update readme
214222
if: inputs.readme_enabled == 'true'
@@ -217,13 +225,15 @@ runs:
217225
env:
218226
GITHUB_TOKEN: "${{ inputs.token }}"
219227
run: |
220-
make readme/build
228+
output_file=$(atmos docs generate ${{ inputs.target }} 2>&1 | sed -n -e "s/^.*output=//p")
229+
# Get relative path from absolute
230+
output_file=$(realpath -s --relative-to="$PWD" "$output_file")
221231
# Ignore changes if they are only whitespace
222-
if ! git diff --quiet README.md && git diff --ignore-all-space --ignore-blank-lines --quiet README.md; then
223-
git restore README.md
224-
echo Ignoring whitespace-only changes in README
232+
if ! git diff --quiet ${output_file} && git diff --ignore-all-space --ignore-blank-lines --quiet ${output_file}; then
233+
git restore ${output_file}
234+
echo Ignoring whitespace-only changes in generated file
225235
fi
226-
echo "file=README.md" >> $GITHUB_OUTPUT
236+
echo "file=${output_file}" >> $GITHUB_OUTPUT
227237
228238
- uses: gaurav-nelson/github-action-markdown-link-check@v1
229239
if: inputs.readme_enabled == 'true' && inputs.validate_readme == 'true'

0 commit comments

Comments
 (0)