Last active
February 8, 2024 20:38
-
-
Save bcavileer/71132e79db086717fc6f03b0faa37257 to your computer and use it in GitHub Desktop.
Apollo Variant Release & Teardown
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
| #! /bin/bash | |
| set -e | |
| cat schema/*.graphql | \ | |
| rover subgraph check \ | |
| --schema - \ | |
| --name retail-graph \ | |
| retail@staging | |
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
| #! /bin/bash | |
| # This script is executed when a release occurs in Heroku | |
| #set -x | |
| set -e | |
| # In Review App environments set variant to the Git Branch name (14-char limit on variant name) | |
| : ${APOLLO_GRAPH_VARIANT:=${HEROKU_BRANCH:0:14}} | |
| # In Review App environments set Routing URL to Review App URL | |
| : ${APOLLO_ROUTING_URL:=https://$HEROKU_APP_NAME.herokuapp.com} | |
| : ${APOLLO_SUPERGRAPH_NAME:=<redacted>} | |
| : ${APOLLO_SUBGRAPH_NAME:=retail-graph} | |
| : ${APOLLO_GRAPH_REF:=$APOLLO_SUPERGRAPH_NAME@$APOLLO_GRAPH_VARIANT} | |
| # Install Rover | |
| curl -sSL https://rover.apollo.dev/nix/v0.21.0 | sh | |
| PATH=$PATH:$HOME/.rover/bin | |
| # Publish the subgraph | |
| cat schema/*.graphql | \ | |
| rover subgraph publish \ | |
| --name $APOLLO_SUBGRAPH_NAME \ | |
| --schema - \ | |
| --routing-url $APOLLO_ROUTING_URL \ | |
| --client-timeout 120 \ | |
| $APOLLO_GRAPH_REF | |
| # Migrate the database | |
| npx prisma migrate deploy |
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
| #! /bin/bash | |
| # This script is executed when a PR Review App is destroyed | |
| #set -x | |
| set -e | |
| # In Review App environments set variant to the Git Branch name (14-char limit on variant name) | |
| : ${APOLLO_GRAPH_VARIANT:=${HEROKU_BRANCH:0:14}} | |
| : ${APOLLO_SUPERGRAPH_NAME:=<redacted>} | |
| : ${APOLLO_GRAPH_REF:=$APOLLO_SUPERGRAPH_NAME@$APOLLO_GRAPH_VARIANT} | |
| if [ $APOLLO_GRAPH_REF == "<redacted>@main" ] || [ $APOLLO_GRAPH_REF == "<redacted>@staging" ] | |
| then | |
| echo "WARNING: Will NOT teardown critical graph $APOLLO_GRAPH_REF!" | |
| exit 1 | |
| fi | |
| # Install Rover | |
| curl -sSL https://rover.apollo.dev/nix/v0.21.0 | sh | |
| PATH=$PATH:$HOME/.rover/bin | |
| # Delete the Review App variant | |
| rover graph delete $APOLLO_GRAPH_REF --confirm --client-timeout 120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment