Skip to content

Sync Forms & Metadata to Destination Repo #139

Sync Forms & Metadata to Destination Repo

Sync Forms & Metadata to Destination Repo #139

name: Sync Forms & Metadata to Destination Repo
on:
schedule:
- cron: '0 2 * * *' # Runs daily at 2 AM UTC
workflow_dispatch: # Allows manual trigger
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Destination Repository
uses: actions/checkout@v4
with:
repository: METS-Programme/ugandaemr-metadata
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Add Upstream Repository
run: |
git remote add upstream https://github.com/mohuganda/openmrs-module-ugandaemr.git || true
git fetch upstream --tags
- name: Force Overwrite Destination Repo with Upstream Changes
run: |
git fetch upstream master
git reset --hard upstream/master # Force overwrite of destination with upstream
- name: Disable Sparse Checkout Warnings
run: git config --global advice.updateSparsePath false # <--- ADDED HERE
- name: Configure Sparse Checkout
run: |
git sparse-checkout init --cone
git sparse-checkout set \
omod/src/main/webapp/resources/htmlforms \
omod/src/main/webapp/resources/jsonforms \
api/src/main/resources/metadata
git pull --no-rebase upstream master # Fetch only sparse paths
- name: Ensure Target Directories Exist
run: |
test -d configuration/forms/htmlforms || mkdir -p configuration/forms/htmlforms
test -d configuration/forms/jsonforms || mkdir -p configuration/forms/jsonforms
test -d configuration/metadata || mkdir -p configuration/metadata
- name: Sync Files from Upstream to Destination Structure
run: |
rsync -av omod/src/main/webapp/resources/htmlforms/ configuration/forms/htmlforms/
rsync -av omod/src/main/webapp/resources/jsonforms/ configuration/forms/jsonforms/
rsync -av api/src/main/resources/metadata/ configuration/metadata/
- name: Commit and Push Changes to Destination
run: |
git add configuration/forms/htmlforms configuration/forms/jsonforms configuration/metadata
git commit -m "Synced resources (htmlforms, jsonforms & metadata) from upstream master" || echo "No changes to commit"
git push origin master || echo "No changes to push"