From f2b2c0de23af68a81c7d4429dc23c32076cd9d8d Mon Sep 17 00:00:00 2001 From: John Teague Date: Thu, 22 May 2025 13:34:13 -0500 Subject: [PATCH 1/2] added sync gh action --- .github/workflows/sync-monorepo.mjs | 11 +++++++ .github/workflows/sync-pr-to-monorepo.yml | 40 +++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/sync-monorepo.mjs create mode 100644 .github/workflows/sync-pr-to-monorepo.yml diff --git a/.github/workflows/sync-monorepo.mjs b/.github/workflows/sync-monorepo.mjs new file mode 100644 index 0000000..7cd12de --- /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 diff --git a/.github/workflows/sync-pr-to-monorepo.yml b/.github/workflows/sync-pr-to-monorepo.yml new file mode 100644 index 0000000..2eef9c5 --- /dev/null +++ b/.github/workflows/sync-pr-to-monorepo.yml @@ -0,0 +1,40 @@ +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 + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - 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: Sync to Monorepo + 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: apps/formio-server + run: | + echo "Syncing PR #${PR_NUMBER}: ${PR_TITLE}" + node .github/workflows/sync-monorepo.mjs \ No newline at end of file From a22ddba244f2c799d3ad7cecbb32185d91e7d46c Mon Sep 17 00:00:00 2001 From: John Teague Date: Thu, 22 May 2025 14:36:41 -0500 Subject: [PATCH 2/2] updated gh workflow --- .github/workflows/sync-pr-to-monorepo.yml | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sync-pr-to-monorepo.yml b/.github/workflows/sync-pr-to-monorepo.yml index 2eef9c5..7de261c 100644 --- a/.github/workflows/sync-pr-to-monorepo.yml +++ b/.github/workflows/sync-pr-to-monorepo.yml @@ -11,12 +11,20 @@ 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/${{ github.event.repository.name }} + MONOREPO_PATH: ${{ github.workspace }}/monorepo steps: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 - name: Setup Node.js uses: actions/setup-node@v4 @@ -26,15 +34,16 @@ jobs: - 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 - 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: apps/formio-server run: | echo "Syncing PR #${PR_NUMBER}: ${PR_TITLE}" - node .github/workflows/sync-monorepo.mjs \ No newline at end of file + node .github/workflows/sync-monorepo.mjs