Skip to content
Merged
Changes from 23 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
36 changes: 19 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ inputs:
required: false
default: 'true'

target:
description: "Configuration name"
command:
description: "Atmos command to generate readme"
required: true
default: 'readme'
default: 'docs generate readme'

validate_readme:
required: false
Expand Down Expand Up @@ -232,15 +232,20 @@ runs:
env:
GITHUB_TOKEN: "${{ inputs.token }}"
run: |
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 ${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=${output_file}" >> $GITHUB_OUTPUT
set +e
atmos ${{ inputs.command }}
# Get all changed files and process them
changed_files=$(git status --porcelain | grep -E "^\s?(M|\?\?)" | cut -c4-)
set -e
for file in $changed_files; do
# Ignore changes if they are only whitespace
if ! git diff --quiet "$file" && git diff --ignore-all-space --ignore-blank-lines --quiet "$file"; then
git restore "$file"
echo "Ignoring whitespace-only changes in generated file: $file"
fi
done
files="$(echo ${changed_files})"
echo "file=${files// /,}" >> $GITHUB_OUTPUT

- uses: gaurav-nelson/github-action-markdown-link-check@v1
if: inputs.readme_enabled == 'true' && inputs.validate_readme == 'true'
Expand All @@ -260,7 +265,7 @@ runs:
commit_user_name: "${{ inputs.commit_user_name }}"
commit_user_email: "${{ inputs.commit_user_email }}"
commit_author: "${{ inputs.commit_author }}"
file_pattern: '${{ steps.banner.outputs.file }} ${{ steps.readme.outputs.file }}'
file_pattern: '${{ steps.banner.outputs.file }},${{ steps.readme.outputs.file }}'
push_options: '${{ inputs.commit_push_options }}'

- uses: actions/github-script@v7
Expand Down Expand Up @@ -300,10 +305,7 @@ runs:
committer: ${{ inputs.commit_author }}
sign-commits: ${{ inputs.sign-commits }}
add-paths: |
${{ steps.banner.outputs.file }}
${{ steps.readme.outputs.file }}
**/README.md
docs/*
${{ steps.banner.outputs.file }},${{ steps.readme.outputs.file }}
body: |-
## what
This is an auto-generated PR that updates the README.md and docs
Expand Down