@davoodmehraban89 / medusa / commits / f8d56d89
Fork 0

Configure controlled daily upstream Medusa update pull requests

davoodmehraban89 committed Oct 13, 2026 at 17:17 UTC f8d56d89cdaf144a1b91d5c7a377f30eccc8c2ff
1 file changed +71
.github/workflows/medusa-upstream-review.yml new
+71
@@ -0,0 +1,71 @@
1 +name: Review Medusa upstream updates
2 +
3 +on:
4 + schedule:
5 + - cron: "17 6 * * *"
6 + workflow_dispatch:
7 +
8 +permissions:
9 + contents: write
10 + pull-requests: write
11 +
12 +concurrency:
13 + group: medusa-upstream-review
14 + cancel-in-progress: false
15 +
16 +jobs:
17 + propose:
18 + runs-on: ubuntu-latest
19 + timeout-minutes: 45
20 + steps:
21 + - name: Check out this repository
22 + uses: actions/checkout@v4
23 + with:
24 + fetch-depth: 1
25 + persist-credentials: true
26 +
27 + - name: Fetch upstream source (no upstream code execution)
28 + run: |
29 + set -euo pipefail
30 + git clone --depth 1 --single-branch --branch develop \
31 + https://github.com/medusajs/medusa.git /tmp/medusa-upstream
32 + echo "UPSTREAM_SHA=$(git -C /tmp/medusa-upstream rev-parse HEAD)" >> "$GITHUB_ENV"
33 +
34 + - name: Prepare review branch with source changes
35 + run: |
36 + set -euo pipefail
37 + git config user.name "github-actions[bot]"
38 + git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
39 + git checkout -B automation/medusa-upstream-review
40 + # Keep local GitHub configuration and workflows intact. These are
41 + # security-sensitive and require separate manual review.
42 + rsync -a --delete \
43 + --exclude='/.git/' \
44 + --exclude='/.github/' \
45 + /tmp/medusa-upstream/ ./
46 + mkdir -p .github
47 + printf '%s\n' "$UPSTREAM_SHA" > .github/medusa-upstream-reviewed-sha
48 + git add -A
49 + if git diff --cached --quiet; then
50 + echo "HAS_CHANGES=false" >> "$GITHUB_ENV"
51 + else
52 + git commit -m "Review Medusa upstream develop at $UPSTREAM_SHA"
53 + git push --force-with-lease origin HEAD:refs/heads/automation/medusa-upstream-review
54 + echo "HAS_CHANGES=true" >> "$GITHUB_ENV"
55 + fi
56 +
57 + - name: Open or update review pull request
58 + if: env.HAS_CHANGES == 'true'
59 + env:
60 + GH_TOKEN: ${{ github.token }}
61 + run: |
62 + set -euo pipefail
63 + if gh pr list --head automation/medusa-upstream-review --base main --state open --json number --jq '.[0].number' | grep -q '[0-9]'; then
64 + echo "Existing review PR updated."
65 + else
66 + gh pr create \
67 + --base main \
68 + --head automation/medusa-upstream-review \
69 + --title "Review upstream Medusa develop updates" \
70 + --body "Source: https://github.com/medusajs/medusa (develop). This PR is for human review only. No automatic merge. The .github directory (including upstream workflows) is intentionally excluded. Inspect changes, especially deletions and local customizations, before merging."
71 + fi