sync with diff-common.sh #5
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: Validate _common.sh Sync | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "templates/AddNewPackage/content/scripts/_common.sh" | |
| - ".github/workflows/validate-common-sync.yaml" | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - "templates/AddNewPackage/content/scripts/_common.sh" | |
| - ".github/workflows/validate-common-sync.yaml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| validate-sync: | |
| name: Validate _common.sh is synced from vm2.DevOps | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout vm2.Templates | |
| uses: actions/checkout@v6 | |
| with: | |
| path: vm2.Templates | |
| - name: Checkout vm2.DevOps (source of truth) | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: vmelamed/vm2.DevOps | |
| path: vm2.DevOps | |
| - name: Compare _common.sh files | |
| run: | | |
| SOURCE="vm2.DevOps/.github/actions/scripts/_common.sh" | |
| TARGET="vm2.Templates/templates/AddNewPackage/content/scripts/_common.sh" | |
| SOURCE_GH="vm2.DevOps/.github/actions/scripts/_common.github.sh" | |
| TARGET_GH="vm2.Templates/templates/AddNewPackage/content/scripts/_common.github.sh" | |
| if ! diff -u "$SOURCE" "$TARGET" || ! diff -u "$SOURCE_GH" "$TARGET_GH"; then | |
| echo "" | |
| echo "❌ ERROR: _common.sh and/or _common.github.sh files are out of sync!" | |
| echo "" | |
| echo "The source of truth are: vm2.DevOps/.github/actions/scripts/_common.sh" and "vm2.DevOps/.github/actions/scripts/_common.github.sh" | |
| echo "" | |
| echo "To fix this, run the following commands:" | |
| echo " cd vm2.Templates" | |
| echo " ./scripts/sync-common-sh.sh" | |
| echo "" | |
| echo " git add templates/AddNewPackage/content/scripts/_common.sh" | |
| echo " git commit -m 'chore: sync _common.sh from vm2.DevOps'" | |
| echo "and/or" | |
| echo " git add templates/AddNewPackage/content/scripts/_common.github.sh" | |
| echo " git commit -m 'chore: sync _common.github.sh from vm2.DevOps'" | |
| echo "" | |
| exit 1 | |
| fi | |
| echo "✅ _common.sh is in sync with vm2.DevOps" |