From a13331c81846f4d5b658182ccd9f7cd348d3a321 Mon Sep 17 00:00:00 2001 From: AmeliaCute <48628282+AmeliaCute@users.noreply.github.com> Date: Thu, 5 Feb 2026 14:40:21 +0000 Subject: [PATCH] Implementing synchronization between api and mdk --- .github/workflows/header-update.yml | 36 ------------ .github/workflows/sync-mdk.yml | 90 +++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/header-update.yml create mode 100644 .github/workflows/sync-mdk.yml diff --git a/.github/workflows/header-update.yml b/.github/workflows/header-update.yml deleted file mode 100644 index 99c7021..0000000 --- a/.github/workflows/header-update.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: "Update submodule to latest" - -on: - pull_request: - branches: [ "master" ] - -permissions: - contents: write - -jobs: - update-submodule: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: recursive - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Config user - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - - name: Update submodule - run: | - git submodule set-branch --branch main include - git submodule update --init --remote include - git add include - if ! git diff --staged --quiet; then - git commit -m "[skip ci] update include submodule to latest main" - git push origin HEAD:${{github.head_ref}} - else - echo "No update required" - fi diff --git a/.github/workflows/sync-mdk.yml b/.github/workflows/sync-mdk.yml new file mode 100644 index 0000000..df61a10 --- /dev/null +++ b/.github/workflows/sync-mdk.yml @@ -0,0 +1,90 @@ +name: "Sync to MDK repository" +on: + workflow_run: + workflows: ["Build and deploy project"] + types: + - completed + branches: + - master +env: + TARGET_REPO: ReDevCafe/FantasyLifeI-ModTemplate +jobs: + sync-include: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Checkout repo API (ModLoader) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: repo-api + + - name: Verify include folder exists + run: | + if [ ! -d "repo-api/include" ]; then + echo "Error: include folder not found in source repo" + exit 1 + fi + echo "Include folder found, contents:" + ls -la repo-api/include + + - name: Get release tag from cd.yml + id: version + run: | + TAG="v$(date +'%Y%m%d.%H%M')" + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "Release tag: $TAG" + + - name: Checkout repo MDK (FLiMod template) + uses: actions/checkout@v4 + with: + repository: ${{ env.TARGET_REPO }} + token: ${{ secrets.REPO_MDK_PAT }} + path: repo-mdk + fetch-depth: 0 + + - name: Update include folder + run: | + echo "Removing old include folder..." + rm -rf repo-mdk/include/* + rm -rf repo-mdk/include/.[!.]* + + echo "Copying new include folder..." + cp -r repo-api/include/* repo-mdk/include/ + + echo "Include folder updated, new contents:" + ls -la repo-mdk/include + + - name: Update MODLOADER_BUILD_VERSION in CMakeLists.txt + working-directory: repo-mdk + run: | + TAG="${{ steps.version.outputs.tag }}" + sed -i "s/set(MODLOADER_BUILD_VERSION[[:space:]]*\"[^\"]*\")/set(MODLOADER_BUILD_VERSION \"$TAG\")/" CMakeLists.txt + grep "MODLOADER_BUILD_VERSION" CMakeLists.txt + + - name: Commit and push to main + working-directory: repo-mdk + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + git add include CMakeLists.txt + + if ! git diff --staged --quiet; then + git commit -m "Update ModLoader to ${{ steps.version.outputs.tag }} + + - Updated include headers + - Updated MODLOADER_BUILD_VERSION in CMakeLists.txt" + git push origin main + else + echo "No changes to commit" + fi + + - name: Create versioned branch + working-directory: repo-mdk + run: | + TAG="${{ steps.version.outputs.tag }}" + BRANCH_NAME="modloader-$TAG" + + git checkout -b $BRANCH_NAME + git push origin $BRANCH_NAME \ No newline at end of file