From f428e0ef6a388ef894fe7c79d30f0ed2e1a4e1ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Vouillon?= <jerome.vouillon@gmail.com>
Date: Thu, 10 Oct 2024 20:45:05 +0200
Subject: [PATCH] Github action: automatically merge with js_of_ocaml

---
 .github/workflows/merge.yml | 39 +++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 .github/workflows/merge.yml

diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml
new file mode 100644
index 000000000..89d4c15ab
--- /dev/null
+++ b/.github/workflows/merge.yml
@@ -0,0 +1,39 @@
+name: Automatic Merge with Js_of_ocaml
+
+on:
+  schedule:
+    - cron: '0 0 * * *'  # Executes daily at midnight UTC
+  workflow_dispatch:  # Allows manual triggering of the workflow
+
+permissions:
+  contents: write
+
+jobs:
+  merge:
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Checkout this repository
+        uses: actions/checkout@v3
+        with:
+          ref: main
+          fetch-depth: 1000
+
+      - name: Set Git committer identity
+        run: |
+          git config user.name github-actions
+          git config user.email github-actions@github.com
+
+      - name: Fetch js_of_ocaml master
+        run: git fetch https://github.com/ocsigen/js_of_ocaml.git master
+
+      - name: Merge js_of_ocaml master into current repository
+        run: git merge FETCH_HEAD
+
+      - name: Push merged changes to 'jsoo-merged' branch
+        run: |
+          if git show-ref --verify --quiet refs/heads/jsoo-merged; then
+            git branch -D jsoo-merged
+          fi
+          git checkout -b jsoo-merged
+          git push --force origin jsoo-merged