Make phase 2 catalog migration idempotent #4
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: Settings refactor phase 2 migration | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| paths: | |
| - 'scripts/phase2_catalog_migration.py' | |
| - '.github/workflows/settings-refactor-phase2.yml' | |
| push: | |
| branches: | |
| - agent/settings-refactor-phase1-safety | |
| paths: | |
| - 'scripts/phase2_catalog_migration.py' | |
| - '.github/workflows/settings-refactor-phase2.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| migrate-catalog: | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} | |
| fetch-depth: 1 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Complete catalog coverage | |
| run: python3 scripts/phase2_catalog_migration.py | |
| - name: Validate migrated catalog | |
| run: | | |
| python3 -m unittest tests/test_settings_audit.py | |
| python3 scripts/settings_audit.py --report settings-audit.json | |
| - name: Commit catalog migration | |
| shell: bash | |
| run: | | |
| if git diff --quiet -- src/settings-catalog.json; then | |
| echo 'Catalog is already migrated.' | |
| exit 0 | |
| fi | |
| git config user.name 'github-actions[bot]' | |
| git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| git add src/settings-catalog.json | |
| git commit -m 'Complete settings catalog coverage for phase 2' | |
| git push origin HEAD:${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} |