Update EFCPT Schema #62
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: Update EFCPT Schema | |
| on: | |
| schedule: | |
| # Run twice daily at 6:00 AM and 6:00 PM UTC | |
| - cron: '0 6,18 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: 'Reason for manual run' | |
| required: false | |
| default: 'Manual schema update check' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: "update-schema-${{ github.ref }}" | |
| cancel-in-progress: true | |
| jobs: | |
| check-and-update-schema: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Download upstream schema | |
| id: download | |
| run: | | |
| UPSTREAM_URL="https://raw.githubusercontent.com/ErikEJ/EFCorePowerTools/master/samples/efcpt-config.schema.json" | |
| LOCAL_PATH="lib/efcpt-config.schema.json" | |
| # Download the upstream schema to a temporary file | |
| if ! curl -f -s -o /tmp/upstream-schema.json "$UPSTREAM_URL"; then | |
| echo "Error: Failed to download upstream schema from $UPSTREAM_URL" >&2 | |
| exit 1 | |
| fi | |
| # If the local schema file does not exist, treat this as a change and create it | |
| if [ ! -f "$LOCAL_PATH" ]; then | |
| echo "Local schema file '$LOCAL_PATH' not found. Creating it from upstream." | |
| mkdir -p "$(dirname "$LOCAL_PATH")" | |
| cp /tmp/upstream-schema.json "$LOCAL_PATH" | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| echo "Changes detected in schema file (local file was missing)" | |
| # Compare the files when the local schema exists | |
| elif diff -q "$LOCAL_PATH" /tmp/upstream-schema.json; then | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| echo "No changes detected in schema file" | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| echo "Changes detected in schema file" | |
| cp /tmp/upstream-schema.json "$LOCAL_PATH" | |
| fi | |
| - name: Create Pull Request | |
| if: steps.download.outputs.has_changes == 'true' | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: 'chore: update efcpt-config.schema.json from upstream' | |
| title: 'chore: Update EFCPT Schema from Upstream' | |
| body: | | |
| This PR updates the `/lib/efcpt-config.schema.json` file to match the upstream version from the EFCorePowerTools repository. | |
| **Source**: https://raw.githubusercontent.com/ErikEJ/EFCorePowerTools/master/samples/efcpt-config.schema.json | |
| This PR was automatically created by the scheduled workflow. | |
| branch: automated/update-efcpt-schema | |
| delete-branch: true | |
| labels: | | |
| dependencies | |
| automated |