Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/schema-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Check for schema updates

on: workflow_dispatch

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 }}
Comment thread
komish marked this conversation as resolved.

- uses: actions/checkout@v4
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" \
--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 }}).
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ diff-check:
ci.fmt: fmt diff-check
echo "=> ci.fmt done"

.PHONY: ci.generate
ci.generate: generate diff-check
echo "=> ci.generate done"

.PHONY: ci.tidy
ci.tidy: tidy diff-check
echo "=> ci.tidy done"
Expand Down