-
Notifications
You must be signed in to change notification settings - Fork 82
[CI] Added job adding preview links #2561
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c271bac
Applied review suggestion
mnocon d9f9ffd
[TMP] Add change
mnocon baa535d
[TMP] Random change 2
mnocon 6677271
Fixed hardcoded master
mnocon ff893fd
Fix?
mnocon bc9ddb0
Fix?
mnocon cea3091
Removed newline
mnocon 0d34f95
Refactoring
mnocon 7a01b22
Revert "[TMP] Add change"
mnocon 9536928
Revert "[TMP] Random change 2"
mnocon d564bb5
Removed file filter from the job
mnocon bcf8182
Refined message
mnocon 7cf53c9
Applied review wording suggestion
mnocon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: "Post preview links for changed files" | ||
|
||
on: | ||
pull_request: ~ | ||
workflow_call: | ||
inputs: | ||
project: | ||
description: 'The project to build (dev doc, user doc)' | ||
default: '' | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
post-preview-links: | ||
name: Post preview links for changed files | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# Needed to manage the comment | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create comment for changed files | ||
run: | | ||
file_limit=100 | ||
build_url="https://ez-systems-developer-documentation--${{ github.event.pull_request.number }}.com.readthedocs.build/${{inputs.project}}en/${{ github.event.pull_request.number }}/" | ||
|
||
change_list=$(git diff --name-only HEAD "origin/$GITHUB_BASE_REF" | grep -E "^docs\/.*\.md$" | sed -E "s|^docs/(.*)\.md$|- [docs/\1.md](${build_url}\1/)|") | ||
change_count=$(echo "$change_list" | wc -l) | ||
|
||
if [[ $change_list -eq '' ]] ; then | ||
comment="Preview of modified Markdown files: no Markdown changes to preview." | ||
elif [[ $change_count -gt $file_limit ]] ; then | ||
comment="Preview of modified Markdown files: Too many files modified in a single PR, preview link list is skipped. ($change_count files >h; $file_limit)" | ||
else | ||
comment="Preview of modified Markdown files:\n\n$change_list" | ||
fi | ||
|
||
echo -e "$comment" > comment.md | ||
|
||
- name: Find comment | ||
id: find-comment | ||
uses: peter-evans/find-comment@v3 | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: 'Preview of modified Markdown files' | ||
|
||
- name: Create or update comment | ||
uses: peter-evans/create-or-update-comment@v4 | ||
with: | ||
comment-id: ${{ steps.find-comment.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-path: comment.md | ||
edit-mode: replace |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.