|
| 1 | +name: Update EFCPT Schema |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run twice daily at 6:00 AM and 6:00 PM UTC |
| 6 | + - cron: '0 6,18 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + reason: |
| 10 | + description: 'Reason for manual run' |
| 11 | + required: false |
| 12 | + default: 'Manual schema update check' |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + pull-requests: write |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: "update-schema-${{ github.ref }}" |
| 20 | + cancel-in-progress: true |
| 21 | + |
| 22 | +jobs: |
| 23 | + check-and-update-schema: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 1 |
| 30 | + |
| 31 | + - name: Download upstream schema |
| 32 | + id: download |
| 33 | + run: | |
| 34 | + UPSTREAM_URL="https://raw.githubusercontent.com/ErikEJ/EFCorePowerTools/master/samples/efcpt-config.schema.json" |
| 35 | + LOCAL_PATH="lib/efcpt-config.schema.json" |
| 36 | + |
| 37 | + # Download the upstream schema to a temporary file |
| 38 | + if ! curl -f -s -o /tmp/upstream-schema.json "$UPSTREAM_URL"; then |
| 39 | + echo "Error: Failed to download upstream schema from $UPSTREAM_URL" >&2 |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | + |
| 43 | + # If the local schema file does not exist, treat this as a change and create it |
| 44 | + if [ ! -f "$LOCAL_PATH" ]; then |
| 45 | + echo "Local schema file '$LOCAL_PATH' not found. Creating it from upstream." |
| 46 | + mkdir -p "$(dirname "$LOCAL_PATH")" |
| 47 | + cp /tmp/upstream-schema.json "$LOCAL_PATH" |
| 48 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 49 | + echo "Changes detected in schema file (local file was missing)" |
| 50 | + # Compare the files when the local schema exists |
| 51 | + elif diff -q "$LOCAL_PATH" /tmp/upstream-schema.json; then |
| 52 | + echo "has_changes=false" >> "$GITHUB_OUTPUT" |
| 53 | + echo "No changes detected in schema file" |
| 54 | + else |
| 55 | + echo "has_changes=true" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Changes detected in schema file" |
| 57 | + cp /tmp/upstream-schema.json "$LOCAL_PATH" |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Create Pull Request |
| 61 | + if: steps.download.outputs.has_changes == 'true' |
| 62 | + uses: peter-evans/create-pull-request@v8 |
| 63 | + with: |
| 64 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + commit-message: 'chore: update efcpt-config.schema.json from upstream' |
| 66 | + title: 'chore: Update EFCPT Schema from Upstream' |
| 67 | + body: | |
| 68 | + This PR updates the `/lib/efcpt-config.schema.json` file to match the upstream version from the EFCorePowerTools repository. |
| 69 | + |
| 70 | + **Source**: https://raw.githubusercontent.com/ErikEJ/EFCorePowerTools/master/samples/efcpt-config.schema.json |
| 71 | + |
| 72 | + This PR was automatically created by the scheduled workflow. |
| 73 | + branch: automated/update-efcpt-schema |
| 74 | + delete-branch: true |
| 75 | + labels: | |
| 76 | + dependencies |
| 77 | + automated |
0 commit comments