1
1
name : Deploy Website to Cloud Run
2
2
3
3
on :
4
- push :
5
- paths :
6
- - website/**
4
+ workflow_dispatch :
5
+ workflow_call :
7
6
8
7
env :
9
8
GEN : " workshop"
@@ -32,22 +31,46 @@ jobs:
32
31
run : |
33
32
docker build -t gcr.io/summit-enterprise-workshop/${{github.actor}}-website:latest .
34
33
docker images
35
- working-directory : ./website
34
+ working-directory : .final /website
36
35
37
36
- name : Push Docker image to Google Container Registry
38
37
run : |
39
38
docker push gcr.io/summit-enterprise-workshop/${{github.actor}}-website:latest
40
- working-directory : ./website
39
+ working-directory : ./final/website
40
+
41
+ - name : Get Router URL
42
+ run : |
43
+ gcloud run services describe ${{vars.ACTOR}}-router --region us-central1 --format 'value(status.url)' > url.json
44
+ echo "URL=$(cat url.json)" >> $GITHUB_ENV
41
45
42
46
- name : Deploy Website to Cloud Run
43
47
run : |
44
48
gcloud run deploy ${{github.actor}}-website \
45
49
--image gcr.io/summit-enterprise-workshop/${{github.actor}}-website:latest \
46
50
--platform managed \
47
51
--region us-central1 \
48
- --update-env-vars APOLLO_KEY=${{ secrets.APOLLO_KEY }},APOLLO_GRAPH_REF=${{ secrets.APOLLO_GRAPH_REF }} \
52
+ --update-env-vars APOLLO_KEY=${{ secrets.APOLLO_KEY }},APOLLO_GRAPH_REF=${{ secrets.APOLLO_GRAPH_REF }}, ROUTER_URL=${{env.url}} \
49
53
--allow-unauthenticated
50
54
- name : Get URL
51
55
run : |
52
56
gcloud run services describe ${{vars.ACTOR}}-website --region us-central1 --format 'value(status.url)' > url.json
53
- echo "::notice URL=$(cat url.json)"
57
+ echo "webURL=$(cat url.json)" >> $GITHUB_ENV
58
+
59
+ - name : Get current README to update
60
+ run : |
61
+ curl --request POST \
62
+ --header 'content-type: application/json' \
63
+ --header 'X-API-Key: user:fp.d88ba77d-487c-4b97-9780-f1e4c5352a22:ftuXT6T7OktKoMaUZhQwSw' \
64
+ --url 'https://graphql.api.apollographql.com/api/graphql' \
65
+ --data '{"query":"query Query($ref: ID!) {\n variant(ref: $ref) {\n ... on GraphVariant {\n readme {\n content\n }\n }\n }\n}","variables":{"ref":"${{vars.ACTOR}}${{env.GEN}}"}}' -o readme.json
66
+
67
+ - name : Set Env
68
+ run : echo "CONTENT=$(cat readme.json | jq .data.variant.readme.content)" >> $GITHUB_ENV
69
+
70
+ - name : Update README
71
+ run : |
72
+ curl --request POST \
73
+ --header 'content-type: application/json' \
74
+ --header 'X-API-Key: user:fp.d88ba77d-487c-4b97-9780-f1e4c5352a22:ftuXT6T7OktKoMaUZhQwSw' \
75
+ --url 'https://graphql.api.apollographql.com/api/graphql' \
76
+ --data '{"query":"mutation Mutation($graphId: ID!, $name: String!, $readme: String!) {\n graph(id: $graphId) {\n variant(name: $name) {\n updateVariantReadme(readme: $readme) {\n readme {\n content\n }\n }\n }\n }\n}","variables":{"graphId":"${{vars.ACTOR}}${{env.GEN}}","name":"current","readme":"${{env.CONTENT}} \n###WEBSITE URL \n ${{env.webURL}}"}}'
0 commit comments