This repository was archived by the owner on Jan 30, 2026. It is now read-only.
Check for schema updates #215
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: Check for schema updates | |
| on: | |
| workflow_dispatch: {} | |
| schedule: | |
| - cron: "0 0 * * *" | |
| jobs: | |
| update: | |
| name: Update generated schema and code for Pyxis | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check for existing pull request | |
| id: check_pr | |
| run: | | |
| pr_count=$(gh pr list --repo "${GITHUB_REPOSITORY}" \ | |
| --state open \ | |
| --json number,url,title \ | |
| --label schema-update \ | |
| --jq '. | length') | |
| echo "Found ${pr_count} pull request(s) currently open for schema update." | |
| echo "pr_count=${pr_count}" | tee -a "${GITHUB_OUTPUT}" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - uses: actions/checkout@v4 | |
| if: ${{ steps.check_pr.outputs.pr_count == '0' }} | |
| - name: Set up Python and uv | |
| uses: ./.github/actions/setup-python-uv | |
| if: ${{ steps.check_pr.outputs.pr_count == '0' }} | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| if: ${{ steps.check_pr.outputs.pr_count == '0' }} | |
| with: | |
| go-version-file: go.mod | |
| - name: Generate changes | |
| if: ${{ steps.check_pr.outputs.pr_count == '0' }} | |
| run: | | |
| # Collect the exit code, but a diff here should not be fatal | |
| set +e | |
| make ci.generate | |
| rc=$? | |
| set -e | |
| if [ "${rc}" != "0" ]; then | |
| # 41898282 is the user id of the GitHub Actions bot. | |
| # https://github.com/actions/checkout#push-a-commit-using-the-built-in-token | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| timestamp=$(date +%s) | |
| git checkout -b "pyxis-schema-update-${timestamp}" | |
| git add internal/genpyxis/schema.graphql internal/genpyxis/generated.go | |
| git commit -m "Update generated schema and code for Pyxis" | |
| git push -u origin "pyxis-schema-update-${timestamp}" | |
| gh pr create --repo "${GITHUB_REPOSITORY}" \ | |
| --title "Update generated schema and code for Pyxis" \ | |
| --label schema-update \ | |
| --body "${PR_BODY}" \ | |
| --base "${BASE_BRANCH}" \ | |
| --head "pyxis-schema-update-${timestamp}" | |
| else | |
| echo "Schema and code generation completed. No changes were detected." | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| BASE_BRANCH: ${{ github.ref_name }} | |
| PR_BODY: | | |
| This pull request was automatically generated by [GitHub Actions](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). |