Sync and Flatten CCMM #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync and Flatten CCMM | |
| on: | |
| repository_dispatch: | |
| types: [ccmm_xsd_updated] | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-and-merge: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout your repository | |
| uses: actions/checkout@v4 | |
| with: | |
| path: destination | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Checkout CCMM source | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: techlib/CCMM | |
| path: source | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: pip install lxml click | |
| - name: Copy XSD directories | |
| run: | | |
| TARGET_DIR="destination/flattenCCMM/mirror-ccmm" | |
| # Vyčištění cíle | |
| if [ -d "$TARGET_DIR" ]; then | |
| rm -rf "$TARGET_DIR"/* | |
| else | |
| mkdir -p "$TARGET_DIR" | |
| fi | |
| cd source | |
| find . -name "*.xsd" > xsd_list.txt | |
| if [ -s xsd_list.txt ]; then | |
| cat xsd_list.txt | xargs cp --parents -t "../$TARGET_DIR/" | |
| echo "Kopírování do $TARGET_DIR dokončeno." | |
| else | |
| echo "Chyba: Žádné XSD nenalezeny." | |
| exit 1 | |
| fi | |
| - name: Run flattenCCMM | |
| run: | | |
| # Přechod do nově pojmenovaného adresáře | |
| cd destination/flattenCCMM | |
| python scripts/merge_schemas.py mirror-ccmm/ output/ccmm_merged.xsd | |
| # 5. Commit a Push | |
| - name: Commit and push | |
| run: | | |
| cd destination | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add flattenCCMM/ | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Update: Synchronized and flattened XSD in flattenCCMM/" | |
| git push origin HEAD | |
| else | |
| echo "No changes to commit" | |
| fi |