Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,39 @@ usage: |-
banner_enabled: true
readme_enabled: true
```

### Migrating from `v0` to `v1`

`v1` use [atmos](https://atmos.tools/cli/commands/docs/generate) instead of [build-harness](https://github.com/cloudposse/build-harness).
You can drop `Makefile` if you use it only for readme generation.
To support atmos reaadme generation, you must create `atmos.yaml` config.
The configuration depends on your repo - please follow this [documentation](https://atmos.tools/cli/commands/docs/generate)

Example:

```yaml filename="atmos.yaml"
docs:
generate:
readme:
base-dir: .
input:
- "./README.yaml"
template: "https://.../README.md.gotmpl"
output: "./README.md"
terraform:
source: src/
enabled: false
format: "markdown"
show_providers: false
show_inputs: true
show_outputs: true
sort_by: "name"
hide_empty: false
indent_level: 2
```

include:
- "docs/github-action.md"

# Contributors to this project
contributors: []
contributors: []
36 changes: 23 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ inputs:
required: false
default: 'true'

target:
description: "Configuration name"
required: true
default: 'readme'

validate_readme:
required: false
default: 'true'
Expand Down Expand Up @@ -92,6 +97,11 @@ inputs:
no-release
readme

atmos-version:
description: The version of atmos to install
required: false
default: '>= 1.175.0'

outputs:
banner_file:
description: "Generated banner file path (if banner_enabled: true)"
Expand Down Expand Up @@ -201,14 +211,12 @@ runs:
viewportHeight: 320
omitBackground: true

- name: Initialize Makefile with `build-harness` support
if: inputs.readme_enabled == 'true'
shell: bash
run: |
if [[ ! -f Makefile ]]; then
echo '-include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness)' > Makefile
fi
make init
- name: Install Atmos
uses: cloudposse/github-action-setup-atmos@v2
with:
atmos-version: ${{ inputs.atmos-version }}
token: ${{ inputs.token }}
install-wrapper: false

- name: Update readme
if: inputs.readme_enabled == 'true'
Expand All @@ -217,13 +225,15 @@ runs:
env:
GITHUB_TOKEN: "${{ inputs.token }}"
run: |
make readme/build
output_file=$(atmos docs generate ${{ inputs.target }} 2>&1 | sed -n -e "s/^.*output=//p")
# Get relative path from absolute
output_file=$(realpath -s --relative-to="$PWD" "$output_file")
# Ignore changes if they are only whitespace
if ! git diff --quiet README.md && git diff --ignore-all-space --ignore-blank-lines --quiet README.md; then
git restore README.md
echo Ignoring whitespace-only changes in README
if ! git diff --quiet ${output_file} && git diff --ignore-all-space --ignore-blank-lines --quiet ${output_file}; then
git restore ${output_file}
echo Ignoring whitespace-only changes in generated file
fi
echo "file=README.md" >> $GITHUB_OUTPUT
echo "file=${output_file}" >> $GITHUB_OUTPUT

- uses: gaurav-nelson/github-action-markdown-link-check@v1
if: inputs.readme_enabled == 'true' && inputs.validate_readme == 'true'
Expand Down