Skip to content

Commit 9629284

Browse files
authored
[GitHub] Broaden redirects comment to include partial checks (#23636)
* [GitHub] Broaden redirects comment to include partial checks * update * update * update * Update * one more update * missing quote * update * one more update * update * More indenation * only grab filename for partials * indentation * Another * remove trailing and leading slashes * update * one more * flip line * change link rendering * final update * ugh * remove partial update * partial only * remove file changes
1 parent ada1ddc commit 9629284

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

.github/workflows/comment-changed-filenames.yml renamed to .github/workflows/potential-redirects-or-partials.yml

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Flag changed filenames
1+
name: Potential redirects or partials
22

33
# **What it does**: Adds or removes a comment if a PR renames or removes a file.
44
# **Why we have it**: Highlights when we need redirects covering certain file paths.
@@ -22,7 +22,7 @@ jobs:
2222
- name: Checkout Repository
2323
uses: actions/checkout@v4
2424

25-
- name: Get Renamed or Removed Files from Pull Request
25+
- name: Potential redirects
2626
env:
2727
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2828
run: |
@@ -37,17 +37,32 @@ jobs:
3737
echo "${files}" >> "$GITHUB_ENV"
3838
echo "${delimiter}" >> "$GITHUB_ENV"
3939
40+
- name: Updated partial files
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
files=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
45+
-H "Accept: application/vnd.github.v3+json" \
46+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \
47+
jq -r '.[] | select(.status=="modified") | select (.filename | startswith("src/content/partials")) | select(.filename | endswith(".mdx")) | .filename' | \
48+
sed -e 's|^src/content/partials||' -e 's|\.mdx$|/|')
49+
# Use random delimiter for security reasons
50+
delimiter="$(openssl rand -hex 8)"
51+
echo "PARTIAL_FILES<<${delimiter}" >> "$GITHUB_ENV"
52+
echo "${files}" >> "$GITHUB_ENV"
53+
echo "${delimiter}" >> "$GITHUB_ENV"
54+
4055
- name: Comment or Update Comment on PR based on changed files
4156
env:
4257
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4358
run: |
4459
# If there are no changed files
45-
if [ -z "$CHANGED_FILES" ]; then
60+
if [ -z "$CHANGED_FILES" ] && [ -z "$PARTIAL_FILES" ]; then
4661
# Fetch the ID of the existing comment, if it exists
4762
existing_comment_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
4863
-H "Accept: application/vnd.github.v3+json" \
4964
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \
50-
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR changes current filenames or deletes current files")) | .id')
65+
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR requires additional review attention because it affects the following areas")) | .id')
5166
5267
# If the comment exists, delete it
5368
if [ ! -z "$existing_comment_id" ]; then
@@ -58,18 +73,39 @@ jobs:
5873
fi
5974
else
6075
# Construct the comment body for changed files
61-
comment_body="This PR changes current filenames or deletes current files. Make sure you have [redirects](https://developers.cloudflare.com/pages/configuration/redirects/) set up to cover the following paths:"
62-
for path in $CHANGED_FILES; do
63-
clean_path=$(echo $path | sed 's/"//g') # Remove quotation marks
76+
comment_body="This PR requires additional review attention because it affects the following areas:"
77+
78+
# Add CHANGED_FILES logic
79+
if [ -n "$CHANGED_FILES" ]; then
6480
comment_body="$comment_body
81+
82+
### Redirects
83+
This PR changes current filenames or deletes current files. Make sure you have [redirects](https://developers.cloudflare.com/pages/configuration/redirects/) set up to cover the following paths:"
84+
for path in $CHANGED_FILES; do
85+
clean_path=$(echo "$path" | sed 's/"//g') # Remove quotation marks
86+
comment_body="$comment_body
6587
- [ ] \`$clean_path\`"
66-
done
88+
done
89+
fi
90+
91+
# Conditional bit for PARTIAL_FILES
92+
if [ -n "$PARTIAL_FILES" ]; then
93+
comment_body="$comment_body
94+
95+
### Partials
96+
This PR updates partial files, which are pieces of content used across multiple files in our [Render component](https://developers.cloudflare.com/style-guide/components/render/)."
97+
for path in $PARTIAL_FILES; do
98+
updated_path=$(echo "$path" | sed -e 's/"//g' -e 's/^\///' -e 's/\/$//')
99+
comment_body="$comment_body
100+
- [ ] \`$updated_path\` - [view affected files](https://developers.cloudflare.com/style-guide/components/render/?partial=$updated_path)"
101+
done
102+
fi
67103
68104
# Check if a comment already exists
69105
existing_comment_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
70106
-H "Accept: application/vnd.github.v3+json" \
71107
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \
72-
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR changes current filenames or deletes current files")) | .id')
108+
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR requires additional review attention because it affects the following areas")) | .id')
73109
74110
comment_payload=$(echo '{}' | jq --arg body "$comment_body" '.body = $body')
75111

src/content/docs/ai-gateway/configuration/manage-gateway.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ pcx_content_type: how-to
33
title: Manage gateways
44
sidebar:
55
order: 4
6-
76
---
87

9-
import { Render } from "~/components"
8+
import { Render } from "~/components";
109

1110
You have several different options for managing an AI Gateway.
1211

@@ -20,10 +19,8 @@ You have several different options for managing an AI Gateway.
2019

2120
:::note
2221

23-
2422
For more details about what settings are available for editing, refer to [Configuration](/ai-gateway/configuration/).
2523

26-
2724
:::
2825

2926
## Delete gateway

0 commit comments

Comments
 (0)