Skip to content

Comment specific preview links for changed files #1341

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 17 commits into from
Jun 11, 2025
Merged

Conversation

bmorelli25
Copy link
Member

@bmorelli25 bmorelli25 commented May 1, 2025

Summary

This PR adds a comment with links from each changed file to the built location in the deployment preview. This comment will be updated every time a new commit is pushed.

Screenshot 2025-05-01 at 3 09 29 PM

@elastic elastic deleted a comment from github-actions bot May 1, 2025
@bmorelli25
Copy link
Member Author

Unfortunately starting with a comment and updating when the deployment completes seems to need perms beyond the general GITHUB_TOKEN. I'm going to remove this functionality for now:

Screenshot 2025-05-01 at 2 38 14 PM

@elastic elastic deleted a comment from github-actions bot May 1, 2025
@elastic elastic deleted a comment from github-actions bot May 1, 2025
@bmorelli25 bmorelli25 marked this pull request as ready for review May 1, 2025 22:13
@bmorelli25 bmorelli25 requested a review from a team as a code owner May 1, 2025 22:13
@bmorelli25 bmorelli25 changed the title Create link-to-changed-files.yml Comment specific preview links for changed files May 1, 2025
"",
...links,
"",
"🔔 *The preview site may take up to **5 minutes** to finish building. These links will become live once it completes.*"
Copy link
Member

@Mpdreamz Mpdreamz May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 minutes? 😢 https://github.com/elastic/docs-content/actions/workflows/docs-build.yml begs to differ!

Its a safe margin I get it 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just spotted the attempts to update on deployment created ❤️ that!

I think adding these permissions to the workflow would be sufficient.

permissions:
  deployments: read

https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#permissions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh snap! Thanks, I'll give this a try

@leemthompo
Copy link
Contributor

@Mpdreamz can we merge this? I was about to open an issue asking for this functionality 🚀

@bmorelli25 bmorelli25 enabled auto-merge (squash) June 11, 2025 15:31
@bmorelli25 bmorelli25 merged commit 220a9c3 into main Jun 11, 2025
6 of 7 checks passed
@bmorelli25 bmorelli25 deleted the bmorelli25-patch-2 branch June 11, 2025 15:33
leemthompo added a commit to elastic/elasticsearch that referenced this pull request Jun 16, 2025
Copies workflow added to `docs-content` repo in elastic/docs-content#1341

• triggers on pull request events (open, reopen, sync)
• comments with URL preview links for changed docs
• fetches all files in the pr using github api
• filters for added/modified .md files, excluding removed files and _snippets/ directory
• transforms file paths into preview urls on docs-v3-preview.elastic.dev
• checks for existing bot comment
  • updates existing comment or creates new one if none exists
leemthompo added a commit to elastic/elasticsearch that referenced this pull request Jun 17, 2025
* [DOCS] Add docs-preview-comment.yml

Copies workflow added to `docs-content` repo in elastic/docs-content#1341

• triggers on pull request events (open, reopen, sync)
• comments with URL preview links for changed docs
• fetches all files in the pr using github api
• filters for added/modified .md files, excluding removed files and _snippets/ directory
• transforms file paths into preview urls on docs-v3-preview.elastic.dev
• checks for existing bot comment
  • updates existing comment or creates new one if none exists

* use pull_request_target, add perms

- changed event trigger from pull_request to pull_request_target
- added permissions for contents: read, issues: write, pull-requests: write
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants