Skip to content

fix(web): upgrade inngest sdk #130

fix(web): upgrade inngest sdk

fix(web): upgrade inngest sdk #130

Workflow file for this run

name: Sync Release Pull Request
on:
push:
branches:
- develop
jobs:
sync-release-pr:
name: Create or update develop → main PR
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Open or update release PR
env:
GH_TOKEN: ${{ secrets.RELEASE_PR_TOKEN }}
DEFAULT_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: "Release: develop → main"
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
set -euo pipefail
export GH_TOKEN="${GH_TOKEN:-$DEFAULT_GH_TOKEN}"
git fetch origin main --prune
COMMIT_COUNT="$(git rev-list --count origin/main..HEAD)"
if [ "$COMMIT_COUNT" -eq 0 ]; then
echo "No commits to merge from develop into main. Skipping release PR sync."
exit 0
fi
BODY_FILE="$(mktemp)"
export BODY_FILE
python3 - <<'PY'
import os
import subprocess
body_file_path = os.environ["BODY_FILE"]
repository = os.environ["GITHUB_REPOSITORY"]
# Get commits that are in develop but not in main
log = subprocess.check_output(
["git", "log", "--pretty=format:%s (%h)", "origin/main..HEAD", "--no-merges"],
text=True,
).strip().splitlines()
# Filter out empty lines
log = [line for line in log if line.strip()]
max_items = 60
items = log[:max_items]
extra = max(len(log) - len(items), 0)
if items:
bullets = [f"- {line}" for line in items]
if extra:
bullets.append(f"- ...and {extra} more commits")
else:
bullets = ["- No new changes since last release"]
summary_lines = [
"This PR syncs `develop` into `main` for the next production release.",
f"It includes **{len(log)}** commit(s) ahead of `main`.",
]
compare_url = f"https://github.com/{repository}/compare/main...develop"
final_lines = [
"## Release Notes",
"",
*summary_lines,
"",
"## Changes",
"",
*bullets,
"",
"## Compare",
"",
f"- Full diff: {compare_url}",
]
with open(body_file_path, "w", encoding="utf-8") as f:
f.write("\n".join(final_lines).rstrip() + "\n")
# Debug: print the generated body
print("Generated PR body:")
print("-" * 40)
with open(body_file_path, "r") as f:
print(f.read())
print("-" * 40)
PY
PR_NUMBER="$(gh pr list --base main --head develop --state open --json number --jq '.[0].number // empty')"
if [ -n "$PR_NUMBER" ]; then
echo "Updating existing PR #$PR_NUMBER"
set +e
EDIT_OUTPUT="$(
gh pr edit "$PR_NUMBER" \
--title "$PR_TITLE" \
--body-file "$BODY_FILE" 2>&1
)"
EDIT_EXIT=$?
set -e
if [ "$EDIT_EXIT" -eq 0 ]; then
echo "$EDIT_OUTPUT"
exit 0
fi
if echo "$EDIT_OUTPUT" | grep -q "Resource not accessible by personal access token"; then
echo "::warning::RELEASE_PR_TOKEN could not edit PR. Falling back to GITHUB_TOKEN."
export GH_TOKEN="$DEFAULT_GH_TOKEN"
gh pr edit "$PR_NUMBER" \
--title "$PR_TITLE" \
--body-file "$BODY_FILE"
exit 0
fi
echo "$EDIT_OUTPUT"
exit "$EDIT_EXIT"
else
echo "Creating new release PR"
set +e
CREATE_OUTPUT="$(
gh pr create \
--base main \
--head develop \
--title "$PR_TITLE" \
--body-file "$BODY_FILE" 2>&1
)"
CREATE_EXIT=$?
set -e
if [ "$CREATE_EXIT" -eq 0 ]; then
echo "$CREATE_OUTPUT"
exit 0
fi
if echo "$CREATE_OUTPUT" | grep -q "No commits between main and develop"; then
echo "No commits between main and develop. Skipping PR creation."
exit 0
fi
if echo "$CREATE_OUTPUT" | grep -q "Resource not accessible by integration"; then
echo "::warning::Unable to create release PR with GitHub Actions token. Add RELEASE_PR_TOKEN secret (PAT with repo scope) to enable automatic creation."
echo "$CREATE_OUTPUT"
exit 0
fi
if echo "$CREATE_OUTPUT" | grep -q "Resource not accessible by personal access token"; then
echo "::warning::RELEASE_PR_TOKEN could not create PR. Falling back to GITHUB_TOKEN."
export GH_TOKEN="$DEFAULT_GH_TOKEN"
set +e
CREATE_OUTPUT_FALLBACK="$(
gh pr create \
--base main \
--head develop \
--title "$PR_TITLE" \
--body-file "$BODY_FILE" 2>&1
)"
CREATE_EXIT_FALLBACK=$?
set -e
if [ "$CREATE_EXIT_FALLBACK" -eq 0 ]; then
echo "$CREATE_OUTPUT_FALLBACK"
exit 0
fi
if echo "$CREATE_OUTPUT_FALLBACK" | grep -q "Resource not accessible by integration"; then
echo "::warning::Unable to create release PR with fallback GITHUB_TOKEN."
echo "$CREATE_OUTPUT_FALLBACK"
exit 0
fi
echo "$CREATE_OUTPUT_FALLBACK"
exit "$CREATE_EXIT_FALLBACK"
fi
echo "$CREATE_OUTPUT"
exit "$CREATE_EXIT"
fi