|
1 |
| -name: Create Studio Account |
| 1 | +name: Setup Studio Account |
2 | 2 |
|
3 | 3 | on:
|
4 |
| - create: |
5 |
| - push: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Initial Setup"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + |
| 9 | +env: |
| 10 | + GEN: "nov15" |
| 11 | + APOLLO_KEY: ${{ secrets.APOLLO_USER_KEY }} |
6 | 12 |
|
7 | 13 | jobs:
|
8 |
| - create: |
| 14 | + publish: |
| 15 | + uses: ./.github/workflows/publish-subgraph.yml |
| 16 | + secrets: inherit |
| 17 | + |
| 18 | + pqs: |
9 | 19 | runs-on: ubuntu-latest
|
10 | 20 | steps:
|
11 |
| - - name: Create Graph in Apollo Studio |
12 |
| - run: | |
13 |
| - echo "GITHUB_ACTOR: ${GITHUB_ACTOR}" |
14 |
| - curl --request POST 'https://graphql.api.apollographql.com' \ |
15 |
| - --header 'content-type: application/json' \ |
16 |
| - --header 'X-API-Key: user:fp.d88ba77d-487c-4b97-9780-f1e4c5352a22:_60kU_wi1yLH1zt60UhxGg' \ |
17 |
| - --data '{"query":"mutation CreateGraph($graphType: GraphType!, $hiddenFromUninvitedNonAdmin: Boolean!, $createGraphId: ID!, $title: String!, $accountId: ID!) {\n account(id: $accountId) {\n createGraph(graphType: $graphType, hiddenFromUninvitedNonAdmin: $hiddenFromUninvitedNonAdmin, id: $createGraphId, title: $title) {\n ... on Service {\n accountId\n }\n }\n }\n }\n \n \n","variables":{"graphType":"SELF_HOSTED_SUPERGRAPH","hiddenFromUninvitedNonAdmin":false,"createGraphId":"${GITUB_ACTOR}","title":"${GITHUB_ACTOR}","accountId":"summit-2023-enterprise-workshop"},"operationName":"CreateGraph"}' |
18 |
| -jobs: |
19 |
| - publish: |
20 |
| - name: Rover Subgraph Publish |
21 |
| - run-on: ubuntu-latest |
| 21 | + - name: Create PQ List |
| 22 | + run: | |
| 23 | + curl --request POST \ |
| 24 | + --header 'content-type: application/json' \ |
| 25 | + --header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ |
| 26 | + --url 'https://graphql.api.apollographql.com/api/graphql' \ |
| 27 | + --data '{"query":"mutation Mutation($graphId: ID!, $name: String!, $description: String, $linkedVariants: [String!]) {\n graph(id: $graphId) {\n createPersistedQueryList(name: $name, description: $description, linkedVariants: $linkedVariants) {\n ... on CreatePersistedQueryListResult {\n persistedQueryList {\n id\n createdAt\n }\n }\n }\n }\n}","variables":{"graphId":"${{vars.ACTOR}}${{ env.GEN }}","name":"pq_list","description":"Our PQ List","linkedVariants":["current"]}}' -o pq.json |
| 28 | + cat pq.json |
| 29 | +
|
| 30 | + - name: Set Env |
| 31 | + run: echo "PQ_ID=$(cat pq.json | jq .data.graph.createPersistedQueryList.persistedQueryList.id)" >> $GITHUB_ENV |
| 32 | + |
| 33 | + - name: Install Rover |
| 34 | + run: | |
| 35 | + curl -sSL https://rover.apollo.dev/nix/v0.19.0 | sh |
| 36 | + echo "$HOME/.rover/bin" >> $GITHUB_PATH |
22 | 37 |
|
| 38 | + - name: Checkout |
| 39 | + uses: actions/checkout@v3 |
| 40 | + |
| 41 | + - name: Publish PQ List |
| 42 | + run: | |
| 43 | + rover persisted-queries publish --graph-id ${{vars.ACTOR}}${{env.GEN}} --list-id ${{env.PQ_ID}} \ |
| 44 | + --manifest ./final/workshop-pq-manifest.json |
| 45 | +
|
| 46 | + deploy: |
| 47 | + needs: publish |
| 48 | + uses: ./.github/workflows/deploy-router.yml |
| 49 | + secrets: inherit |
| 50 | + |
| 51 | + install-url: |
| 52 | + needs: deploy |
| 53 | + runs-on: ubuntu-latest |
| 54 | + steps: |
| 55 | + - id: "auth" |
| 56 | + uses: "google-github-actions/auth@v0" |
| 57 | + with: |
| 58 | + credentials_json: ${{ secrets.GCP_CREDENTIALS }} |
| 59 | + - name: Get URL |
| 60 | + run: | |
| 61 | + gcloud run services describe ${{vars.ACTOR}}-router --region us-central1 --format 'value(status.url)' > url.json |
| 62 | + echo "URL=$(cat url.json)" >> $GITHUB_ENV |
| 63 | + - name: Set URL |
| 64 | + run: | |
| 65 | + curl --request POST \ |
| 66 | + --header 'content-type: application/json' \ |
| 67 | + --header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ |
| 68 | + --url 'https://graphql.api.apollographql.com/api/graphql' \ |
| 69 | + --data '{"query":"mutation UpdateURL($name: String!, $graphId: ID!, $url: String) {\n graph(id: $graphId) {\n variant(name: $name) {\n updateURL(url: $url) {\n createdAt\n }\n }\n }\n}","variables":{"name":"current","graphId":"${{vars.ACTOR}}${{ env.GEN }}","url":"${{ env.URL }}"}}' |
| 70 | +
|
| 71 | + - name: Set Subscription URL |
| 72 | + run: | |
| 73 | + curl --request POST \ |
| 74 | + --header 'content-type: application/json' \ |
| 75 | + --header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ |
| 76 | + --url 'https://graphql.api.apollographql.com/api/graphql' \ |
| 77 | + --data '{"query":"mutation Mutation($graphId: ID!, $name: String!, $subscriptionUrl: String) {\n graph(id: $graphId) {\n variant(name: $name) {\n updateSubscriptionURL(subscriptionUrl: $subscriptionUrl) {\n createdAt\n }\n }\n }\n}","variables":{"graphId":"${{vars.ACTOR}}${{ env.GEN }}","name":"current","subscriptionUrl":"${{ env.URL }}"}}' |
| 78 | + |
| 79 | + preflightScript: |
| 80 | + needs: publish |
| 81 | + runs-on: ubuntu-latest |
23 | 82 | steps:
|
24 |
| - - name: Checkout |
25 |
| - uses: actions/checkout@v3 |
26 |
| - |
27 |
| - - name: Install Rover |
28 |
| - run: | |
29 |
| - curl -sSL https://rover.apollo.dev/nix/v0.8.1 | sh |
30 |
| - echo "$HOME/.rover/bin" >> $GITHUB_PATH |
31 |
| -
|
32 |
| - - name: Rover Subgraph Publish |
33 |
| - run: | |
34 |
| - rover subgraph publish ${{secrets.APOLLO_GRAPH_REF }} \ |
35 |
| - --name products \ |
36 |
| - --routing-url https://https://subgraph-products-j3nprurqka-ue.a.run.app \ |
37 |
| - --schema ./final/nosql-products/schema.graphql |
| 83 | + - name: Create PreFlight Script |
| 84 | + run: | |
| 85 | + curl --request POST \ |
| 86 | + --header 'content-type: application/json' \ |
| 87 | + --header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ |
| 88 | + --url 'https://graphql.api.apollographql.com/api/graphql' \ |
| 89 | + --data '{"query":"mutation Mutation($graphId: ID!, $name: String!, $preflightScript: String) {\n graph(id: $graphId) {\n variant(name: $name) {\n updatePreflightScript(preflightScript: $preflightScript) {\n createdAt\n }\n }\n }\n}","variables":{"graphId":"${{vars.ACTOR}}${{ env.GEN }}","name":"current","preflightScript":"const API_KEY=\"AIzaSyBGEWuarfRs4vVIzbdPj7EU_h3tMAVO_e4\";console.log(\"fetching new token.....\");const getToken=async e=>{let o=await explorer.fetch(\"https:\/\/identitytoolkit.googleapis.com\/v1\/accounts:signInWithPassword?key=AIzaSyBGEWuarfRs4vVIzbdPj7EU_h3tMAVO_e4\",{method:\"POST\",header:{\"Content-Type\":\"application\/json\"},body:JSON.stringify({email:e,password:\"apolloworkshop\",returnSecureToken:!0})});return o.json()},authorizedCredentials=await getToken(\"[email protected]\"),{idToken:authorizedToken}=authorizedCredentials;explorer.environment.set(\"authorizedToken\",authorizedToken),console.log(\"successfully set authorized token\");const unauthorizedCredentials=await getToken(\"[email protected]\"),{idToken:unauthorizedToken}=unauthorizedCredentials;explorer.environment.set(\"unauthorizedToken\",unauthorizedToken),console.log(\"successfully set token unauthorized token\");"}}' |
0 commit comments