-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (116 loc) · 3.67 KB
/
Copy pathapollo-validate-push.yaml
File metadata and controls
129 lines (116 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Apollo GraphQL Validate and Push
on:
workflow_call:
inputs:
PUBLIC_PORT:
type: string
required: false
default: "3000"
PRIVATE_PORT:
type: string
required: false
default: "3001"
PUBLISH:
type: boolean
required: false
default: false
GRAPH_REF:
type: string
required: true
GRAPH_NAME:
type: string
required: true
NODE_VERSION:
type: string
required: false
default: "20"
WORKING_DIRECTORY:
type: string
required: false
default: "."
HAS_PUBLIC:
type: boolean
required: false
default: true
HAS_PRIVATE:
type: boolean
required: false
default: true
secrets:
APOLLO_KEY_PUBLIC:
required: true
APOLLO_KEY_PRIVATE:
required: true
jobs:
validate:
defaults:
run:
shell: bash
working-directory: ${{ inputs.WORKING_DIRECTORY }}
runs-on: ubuntu-22.04
steps:
- name: checkout
uses: actions/checkout@v4.2.2
- name: setup node
uses: actions/setup-node@v6.4.0
with:
node-version: ${{ inputs.NODE_VERSION }}
cache: "npm"
cache-dependency-path: ${{ inputs.WORKING_DIRECTORY }}/package-lock.json
- name: install apollo rover cli
uses: apollographql-gh-actions/install-rover@v1.0.2
with:
version: 0.6.0
- name: npm install
run: npm ci
- name: start application
run: npm start &
- name: wait for application to be ready
run: |
for i in {1..30}; do
if curl -s http://localhost:3000 > /dev/null; then
echo "Application is ready"
exit 0
else
echo "Waiting for application to be ready..."
sleep 2
fi
done
- name: fetch subgraph schema (public)
if: ${{ inputs.HAS_PUBLIC }}
run: rover subgraph introspect http://localhost:${{ inputs.PUBLIC_PORT }} > schema.public.graphql
- name: fetch subgraph schema (private)
if: ${{ inputs.HAS_PRIVATE }}
run: rover subgraph introspect http://localhost:${{ inputs.PRIVATE_PORT }} > schema.private.graphql
- name: check schema changes (public)
if: ${{ inputs.HAS_PUBLIC }}
uses: apollographql-gh-actions/rover-subgraph-check@v1
with:
apollo-key: ${{ secrets.APOLLO_KEY_PUBLIC }}
graph-ref: ${{ inputs.GRAPH_REF }}
name: ${{ inputs.GRAPH_NAME }}
schema: ./schema.public.graphql
- name: check schema changes (private)
if: ${{ inputs.HAS_PRIVATE }}
uses: apollographql-gh-actions/rover-subgraph-check@v1
with:
apollo-key: ${{ secrets.APOLLO_KEY_PRIVATE }}
graph-ref: ${{ inputs.GRAPH_REF }}
name: ${{ inputs.GRAPH_NAME }}
schema: ./schema.private.graphql
- name: publish schema (public)
if: ${{ inputs.PUBLISH && inputs.HAS_PUBLIC }}
uses: apollographql-gh-actions/rover-subgraph-publish@v1
with:
apollo-key: ${{ secrets.APOLLO_KEY_PUBLIC }}
graph-ref: ${{ inputs.GRAPH_REF }}
name: ${{ inputs.GRAPH_NAME }}
schema: ./schema.public.graphql
- name: publish schema (private)
if: ${{ inputs.PUBLISH && inputs.HAS_PRIVATE }}
uses: apollographql-gh-actions/rover-subgraph-publish@v1
with:
apollo-key: ${{ secrets.APOLLO_KEY_PRIVATE }}
graph-ref: ${{ inputs.GRAPH_REF }}
name: ${{ inputs.GRAPH_NAME }}
schema: ./schema.private.graphql