stuff #26
This file contains 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: Create Studio Account | |
on: | |
create: | |
push: | |
paths: | |
- '**.yml' | |
jobs: | |
create: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create Graph in Apollo Studio | |
run: | | |
echo "GITHUB_ACTOR: $GITHUB_ACTOR" | |
curl --request POST 'https://graphql.api.apollographql.com' \ | |
--header 'content-type: application/json' \ | |
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | |
--data '{"query":"mutation Mutation($accountId: ID!, $graphType: GraphType!, $hiddenFromUninvitedNonAdmin: Boolean!, $createGraphId: ID!, $title: String!, $variantCreationConfig: VariantCreationConfig) {\n account(id: $accountId) {\n createGraph(graphType: $graphType, hiddenFromUninvitedNonAdmin: $hiddenFromUninvitedNonAdmin, id: $createGraphId, title: $title, variantCreationConfig: $variantCreationConfig) {\n __typename\n ... on Service {\n __typename\n id\n }\n ... on GraphCreationError {\n __typename\n message\n }\n }\n }\n}","variables":{"accountId":"summit-2023-enterprise-workshop","graphType":"SELF_HOSTED_SUPERGRAPH","hiddenFromUninvitedNonAdmin":false,"createGraphId":"${{github.actor}}-2023-1","title":"${{github.actor}}","variantCreationConfig":{"variantName":"current","buildConfigInput":{"apiDirectivePassThrough":[],"buildPipelineTrack":null,"composition":{"subgraphs":[]}}}}}' | |
keys: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Sleep | |
run: sleep 10s | |
shell: bash | |
- name: Create Apollo Key | |
run: | | |
sleep 10 | |
curl --request POST 'https://graphql.api.apollographql.com' \ | |
--header 'content-type: application/json' \ | |
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | |
--data '{"query":"mutation Mutation($graphId: ID!, $keyName: String, $role: UserPermission!) {\n graph(id: $graphId) {\n newKey(keyName: $keyName, role: $role) {\n token\n }\n }\n}","variables":{"graphId":"${{github.actor}}-2023-1","keyName":"my-first-key","role":"CONTRIBUTOR"}}' -o token.json | |
- name: Retrieve Apollo Key | |
run: | | |
echo "Add code to extract token and save as a github secret" | |
echo "TOKEN=$(cat token.json | jq .data.graph.newKey.token)" >> $GITHUB_ENV | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GH_KEY }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/apollosolutions/${{github.repository}}/actions/variables \ | |
-d '{"name":"token","value":"${{ env.TOKEN }}"}' | |
publish: | |
uses: ./.github/workflows/publish-subgraph.yml | |
secrets: inherit | |
pqs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create PQ List | |
run: | | |
curl --request POST \ | |
--header 'content-type: application/json' \ | |
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | |
--url 'https://graphql.api.apollographql.com/api/graphql' \ | |
--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 createdAt\n }\n }\n }\n }\n}","variables":{"graphId":"${{github.actor}}-2023-1","name":"pq_list","description":"Our PQ List","linkedVariants":["current"]}}' | |
- name: Publish PQ List | |
run: | | |
rover persisted-queries publish Summit-SE-Workshop@current \ | |
--manifest ./workshop-pq-manifest.json | |
deploy: | |
uses: ./.github/workflows/deploy-router.yml | |
secrets: inherit | |
install-url: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get URL | |
run: | | |
gcloud run services describe ${{github.actor}}-router --region us-central1 --format 'value(status.url)' > url.json | |
echo "URL=$(cat url.json)" >> $GITHUB_ENV | |
- name: Set URL | |
run: | | |
curl --request POST \ | |
--header 'content-type: application/json' \ | |
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | |
--url 'https://graphql.api.apollographql.com/api/graphql' \ | |
--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":"${{github.actor}}-2023-1","url":"${{ env.URL }}"}}' | |