diff --git a/.github/workflows/schema.yml b/.github/workflows/schema.yml new file mode 100644 index 0000000..c110dbd --- /dev/null +++ b/.github/workflows/schema.yml @@ -0,0 +1,55 @@ +name: Schema + +on: + push: + pull_request: + +jobs: + generate_publish: + # Deduplicate jobs from pull requests and branch pushes within the same repo. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v4.1.2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1.0.7 + with: + toolchain: stable + default: true + + - name: Cache Rust Build + uses: Swatinem/rust-cache@v2.7.3 + + - name: Generate Schema + uses: actions-rs/cargo@v1.0.3 + with: + command: run + args: > + schema + --path sessions.graphql + + - name: Upload Schema Artifact + uses: actions/upload-artifact@v4.3.1 + with: + name: sessions.graphql + path: sessions.graphql + + - name: Check subgraph schema + uses: danielsinclair/rover-setup@v1.0.0 + with: + args: | + subgraph check data-gateway@current + --schema sessions.graphql + --name sessions + + - name: Publish subgraph schema to Apollo Studio + if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }} + uses: danielsinclair/rover-setup@v1.0.0 + with: + args: | + subgraph publish data-gateway@current + --routing-url http://sessions:80 + --schema sessions.graphql + --name sessions