Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Flag changed filenames
name: Potential redirects or partials

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

- name: Get Renamed or Removed Files from Pull Request
- name: Potential redirects
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand All @@ -37,17 +37,32 @@ jobs:
echo "${files}" >> "$GITHUB_ENV"
echo "${delimiter}" >> "$GITHUB_ENV"

- name: Updated partial files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
files=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \
jq -r '.[] | select(.status=="modified") | select (.filename | startswith("src/content/partials")) | select(.filename | endswith(".mdx")) | .filename' | \
sed -e 's|^src/content/partials||' -e 's|\.mdx$|/|')
# Use random delimiter for security reasons
delimiter="$(openssl rand -hex 8)"
echo "PARTIAL_FILES<<${delimiter}" >> "$GITHUB_ENV"
echo "${files}" >> "$GITHUB_ENV"
echo "${delimiter}" >> "$GITHUB_ENV"

- name: Comment or Update Comment on PR based on changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# If there are no changed files
if [ -z "$CHANGED_FILES" ]; then
if [ -z "$CHANGED_FILES" ] && [ -z "$PARTIAL_FILES" ]; then
# Fetch the ID of the existing comment, if it exists
existing_comment_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR changes current filenames or deletes current files")) | .id')
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR requires additional review attention because it affects the following areas")) | .id')

# If the comment exists, delete it
if [ ! -z "$existing_comment_id" ]; then
Expand All @@ -58,18 +73,39 @@ jobs:
fi
else
# Construct the comment body for changed files
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:"
for path in $CHANGED_FILES; do
clean_path=$(echo $path | sed 's/"//g') # Remove quotation marks
comment_body="This PR requires additional review attention because it affects the following areas:"

# Add CHANGED_FILES logic
if [ -n "$CHANGED_FILES" ]; then
comment_body="$comment_body

### Redirects
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:"
for path in $CHANGED_FILES; do
clean_path=$(echo "$path" | sed 's/"//g') # Remove quotation marks
comment_body="$comment_body
- [ ] \`$clean_path\`"
done
done
fi

# Conditional bit for PARTIAL_FILES
if [ -n "$PARTIAL_FILES" ]; then
comment_body="$comment_body

### Partials
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/)."
for path in $PARTIAL_FILES; do
updated_path=$(echo "$path" | sed -e 's/"//g' -e 's/^\///' -e 's/\/$//')
comment_body="$comment_body
- [ ] \`$updated_path\` - [view affected files](https://developers.cloudflare.com/style-guide/components/render/?partial=$updated_path)"
done
fi

# Check if a comment already exists
existing_comment_id=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | \
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR changes current filenames or deletes current files")) | .id')
jq '.[] | select(.user.id == 41898282) | select(.body | contains("This PR requires additional review attention because it affects the following areas")) | .id')

comment_payload=$(echo '{}' | jq --arg body "$comment_body" '.body = $body')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ pcx_content_type: how-to
title: Manage gateways
sidebar:
order: 4

---

import { Render } from "~/components"
import { Render } from "~/components";

You have several different options for managing an AI Gateway.

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

:::note


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


:::

## Delete gateway
Expand Down
Loading