-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI] Added job adding preview links #2561
base: master
Are you sure you want to change the base?
Conversation
f45d0fd
to
c47f2fe
Compare
c47f2fe
to
3cf1b26
Compare
number_of__changed_files=$(echo "$changed_files" | wc -l) | ||
|
||
if [[ $changed_files -eq "" ]] ; then | ||
comment="Preview of modified files:: no markdown files changed, no preview needed." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I modify a code sample, a preview is needed. I would reword to stick to the scope.
comment="Preview of modified files:: no markdown files changed, no preview needed." | |
comment="Preview of modified Markdown files:: No Markdown change to preview." |
|
||
if [[ $changed_files -eq "" ]] ; then | ||
comment="Preview of modified files:: no markdown files changed, no preview needed." | ||
elif [[ $number_of__changed_files -gt file_limit ]] ; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works without the dollar??
elif [[ $number_of__changed_files -gt file_limit ]] ; then | |
elif [[ $number_of__changed_files -gt $file_limit ]] ; then |
if [[ $changed_files -eq "" ]] ; then | ||
comment="Preview of modified files:: no markdown files changed, no preview needed." | ||
elif [[ $number_of__changed_files -gt file_limit ]] ; then | ||
comment="Preview of modified files: too many files modified in a single PR. Unable to post preview links, sorry!" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment="Preview of modified files: too many files modified in a single PR. Unable to post preview links, sorry!" | |
comment="Preview of modified Markdown files: Too many files modified in a single PR, preview link list is skipped. ($number_of__changed_files files >h; $file_limit)" |
right=$(yes ")\n" | head -n "$number_of__changed_files" ) | ||
|
||
comment=$(paste -d'\0' <(echo "$left") <(echo "$filenames") <(echo "$middle") <(echo "$urls") <(echo "$right")) | ||
comment="Preview of modified files:\n\n$comment" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment="Preview of modified files:\n\n$comment" | |
comment="Preview of modified Markdown files:\n\n$comment" |
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: 'Preview of modified files' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body-includes: 'Preview of modified files' | |
body-includes: 'Preview of modified Markdown files' |
changed_files=$(git diff --name-only HEAD "origin/$GITHUB_BASE_REF" | grep -E ".md$" || [[ $? == 1 ]]) | ||
number_of__changed_files=$(echo "$changed_files" | wc -l) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manage to generate the whole link list in one go:
git diff --name-only HEAD "origin/master" | grep -E "^docs\/.*\.md$" | sed -E "s|^docs/(.*)\.md$|- [docs/\1.md](${build_url}\1/)|"
Target: master, 4.6, 3.3 and user doc as a follow-up.
Adding a job to automatically generate preview links for all the changed Markdown files, so that we don't have to do this manually. See the comment below.
IMPORTANT NOTE
Contains TMP changes (borrowed from #2560) to test the job - only the
.github/workflows/preview_comment.yaml
file should be reviewed.Option 1: No Markdown changes in the
docs
directoryThe job doesn't run, there's a filter in the job trigger
Option 2: Markdown changes
See the bot comment below: #2561 (comment)
Option 3: Too many changes
I've chosen an arbitrary limit of 100 files - we can adjust it if needed.