From 2486ca730060e129322e24ba08c7039047aa53de Mon Sep 17 00:00:00 2001 From: John Teague Date: Wed, 21 May 2025 22:52:32 -0500 Subject: [PATCH 1/3] added monorepo sync action --- .github/workflows/monorepo-sync.yml | 49 +++++++++++++++++++++++++++++ .github/workflows/sync-monorepo.mjs | 11 +++++++ 2 files changed, 60 insertions(+) create mode 100644 .github/workflows/monorepo-sync.yml create mode 100644 .github/workflows/sync-monorepo.mjs diff --git a/.github/workflows/monorepo-sync.yml b/.github/workflows/monorepo-sync.yml new file mode 100644 index 00000000..c5e25eba --- /dev/null +++ b/.github/workflows/monorepo-sync.yml @@ -0,0 +1,49 @@ +name: Sync Merged PR to Monorepo + +on: + pull_request: + types: [closed] + branches: + - main + - master + +jobs: + sync-to-monorepo: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ secrets.MONOREPO_SYNC_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + SOURCE_REPO_NAME: ${{ github.event.repository.name }} + MONOREPO_PACKAGE_LOCATION: packages/build-tools + MONOREPO_PATH: ${{ github.workspace }}/monorepo + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install dependencies + # Install project dependencies (including dev dependencies) + run: npm install + - name: Install zx + run: npm install zx + + - name: Install monorepo-sync package + run: npm install git+https://github.com/formio/monorepo-sync.git + - name: Clone Monorepo + run: | + gh repo clone formio/formio-monorepo monorepo -- --depth=1 + + - name: Sync to Monorepo + run: | + echo "Syncing PR #${PR_NUMBER}: ${PR_TITLE}" + node .github/workflows/sync-monorepo.mjs \ No newline at end of file diff --git a/.github/workflows/sync-monorepo.mjs b/.github/workflows/sync-monorepo.mjs new file mode 100644 index 00000000..44f763f2 --- /dev/null +++ b/.github/workflows/sync-monorepo.mjs @@ -0,0 +1,11 @@ +import { syncFromGithubAction } from 'monorepo-sync'; + +syncFromGithubAction() + .then(() => { + console.log('Sync completed successfully'); + process.exit(0); + }) + .catch((error) => { + console.error('Error during sync:', error); + process.exit(1); + }); \ No newline at end of file From d9b3f997c7392e623fdf892fff8321169e32b0fb Mon Sep 17 00:00:00 2001 From: John Teague Date: Wed, 21 May 2025 22:53:43 -0500 Subject: [PATCH 2/3] paramterized package location var --- .github/workflows/monorepo-sync.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/monorepo-sync.yml b/.github/workflows/monorepo-sync.yml index c5e25eba..41deed4d 100644 --- a/.github/workflows/monorepo-sync.yml +++ b/.github/workflows/monorepo-sync.yml @@ -17,7 +17,7 @@ jobs: PR_TITLE: ${{ github.event.pull_request.title }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} SOURCE_REPO_NAME: ${{ github.event.repository.name }} - MONOREPO_PACKAGE_LOCATION: packages/build-tools + MONOREPO_PACKAGE_LOCATION: packages/${{ github.event.repository.name }} MONOREPO_PATH: ${{ github.workspace }}/monorepo steps: From dcdc28fa38188cc9c2fc9515ec7a74a752a69950 Mon Sep 17 00:00:00 2001 From: John Teague Date: Thu, 22 May 2025 14:13:34 -0500 Subject: [PATCH 3/3] updated gh workflow --- .github/workflows/sync-monorepo.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-monorepo.mjs b/.github/workflows/sync-monorepo.mjs index 44f763f2..0f32383b 100644 --- a/.github/workflows/sync-monorepo.mjs +++ b/.github/workflows/sync-monorepo.mjs @@ -8,4 +8,5 @@ syncFromGithubAction() .catch((error) => { console.error('Error during sync:', error); process.exit(1); - }); \ No newline at end of file + }); + \ No newline at end of file