Skip to content

CLI migration guide #652

CLI migration guide

CLI migration guide #652

Workflow file for this run

name: PR Styling
on:
# This has to be pull_request_target since its editing but
# that means the the version from main runs not the PR's
pull_request_target:
types: [opened, synchronize, reopened, edited]
permissions:
contents: read
pull-requests: write
concurrency:
group: pr-description-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
update-description:
runs-on: ubuntu-slim
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Update PR description
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# Fetch the PR branch since we are on base repo
git fetch origin "refs/pull/${PR_NUMBER}/head"
CURRENT_BODY="$(gh pr view "$PR_NUMBER" --json body -q .body)"
NEW_BODY_FILE="$(mktemp)"
printf '%s' "$CURRENT_BODY" \
| ./scripts/format_pr.sh "origin/$PR_BASE_REF" "$PR_HEAD_SHA" \
> "$NEW_BODY_FILE"
NEW_BODY="$(cat "$NEW_BODY_FILE")"
if [ "$CURRENT_BODY" = "$NEW_BODY" ]; then
echo "PR body is already up to date, skipping update."
rm -f "$NEW_BODY_FILE"
exit 0
fi
gh pr edit "$PR_NUMBER" --body-file "$NEW_BODY_FILE"
rm -f "$NEW_BODY_FILE"