-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): getting a bot to comment on docs PRs with docs previews (#…
…4600) This PR makes it substantially easy to review and see changes in PRs containing docs changes by deploying a preview and commenting on the PR with a link to that preview. There are a few changes worth mentioning: - The deploy/non-deploy logic is moved from the CircleCI config to the downstream script `deploy_netlify` - This script will always deploy in prod when PRs are merged, so no change in logic here. - But now, the script gets that PR's file changes via the Github API and checks if there are changes in docs. If there are, then the deploy runs without the `--prod` flag, which will deploy a preview only - It then parses the output searching for the Unique URL which is passed to the bot comment logic - The bot comment logic is changed so it can be reused, by basically adding an enum for the different comment markdowns and importing them dynamically This way, the deploy only runs in PRs that have changes in docs, commenting on those PRs with a deploy preview. When merged, changes are deployed in prod.
- Loading branch information
1 parent
811d767
commit 8307dad
Showing
10 changed files
with
95 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,8 @@ | ||
import { COMMENT_TYPES } from '../types.js'; | ||
import main from '../utils/comment.js'; | ||
|
||
void main(COMMENT_TYPES.DOCS).catch(err => { | ||
// eslint-disable-next-line no-console | ||
console.error(err.message); | ||
process.exit(1); | ||
}); |
This file contains 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,15 @@ | ||
const url = process.env.UNIQUE_DEPLOY_URL as string; | ||
const cleanUrl = (str: string) => | ||
// eslint-disable-next-line no-control-regex | ||
str.replace(/[\u001B\u009B][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, ''); | ||
|
||
const COMMENT_MARK = '<!-- AUTOGENERATED DOCS COMMENT -->'; | ||
|
||
export function getMarkdown() { | ||
return ` | ||
# Docs Preview | ||
Hey there! 👋 You can check your preview at ${cleanUrl(url)} | ||
${COMMENT_MARK} | ||
`; | ||
} |
This file contains 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,4 @@ | ||
export enum COMMENT_TYPES { | ||
BENCH = '<!-- AUTOGENERATED BENCHMARK COMMENT -->', | ||
DOCS = '<!-- AUTOGENERATED DOCS COMMENT -->', | ||
} |
This file contains 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
This file contains 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