-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (133 loc) · 4.95 KB
/
ci.yml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Cosmo Previews
on:
pull_request:
branches:
- main
types:
- opened
- reopened
- closed
- synchronize
jobs:
create:
runs-on: ubuntu-latest
if: github.event.action == 'opened' || github.event.action == 'reopened'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20.10.0
cache: npm
- name: Install wgc
run: npm i -g wgc@latest
# 1. Create & Publish feature subgraph based on cosmo.yaml
# 2. Create a new feature flag
- uses: wundergraph/[email protected]
id: ff
with:
config_path: .github/cosmo.yaml
create: true # Create the feature flag + subgraphs from cosmo.yaml
cosmo_api_key: ${{ secrets.COSMO_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "${{ steps.ff.outputs.feature_subgraphs_to_deploy }}"
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy apps to Fly.io
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
cd demos/go
echo '${{ steps.ff.outputs.feature_subgraphs_to_deploy }}' | jq -c '.[]' | while read -r subgraph; do
name=$(echo "$subgraph" | jq -r '.featureSubgraphName')
baseSubgraphName=$(echo "$subgraph" | jq -r '.baseSubgraphName')
dockerFilePath=./Dockerfile.$baseSubgraphName
flyctl launch --name $name --region lax --dockerfile $dockerFilePath --org wundergraph-demos --yes
done
update:
runs-on: ubuntu-latest
if: github.event.action == 'synchronize'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20.10.0
cache: npm
- name: Install wgc
run: npm i -g wgc@latest
- uses: wundergraph/[email protected]
id: ff
with:
config_path: .github/cosmo.yaml
update: true # Only update the feature subgraphs from cosmo.yaml
cosmo_api_key: ${{ secrets.COSMO_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "${{ steps.ff.outputs.feature_subgraphs_to_deploy }}"
echo "${{ steps.ff.outputs.feature_subgraphs_to_destroy }}"
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy or update apps on Fly.io
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
cd demos/go
echo '${{ steps.ff.outputs.feature_subgraphs_to_deploy }}' | jq -c '.[]' | while read -r subgraph; do
name=$(echo "$subgraph" | jq -r '.featureSubgraphName')
baseSubgraphName=$(echo "$subgraph" | jq -r '.baseSubgraphName')
dockerFilePath=./Dockerfile.$baseSubgraphName
echo $name
echo $baseSubgraphName
echo $dockerFilePath
if flyctl apps list | grep -q $name; then
echo "Updating $name"
flyctl deploy --app $name --dockerfile $dockerFilePath --yes
else
flyctl launch --name $name --region lax --dockerfile $dockerFilePath --org wundergraph-demos --yes
fi
done
echo '${{ steps.ff.outputs.feature_subgraphs_to_destroy }}' | jq -c '.[]' | while read -r subgraph; do
name=$(echo "$subgraph" | jq -r '.featureSubgraphName')
flyctl apps destroy $name --yes
done
destroy:
runs-on: ubuntu-latest
if: github.event.action == 'closed'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20.10.0
cache: npm
- name: Install wgc
run: npm i -g wgc@latest
- uses: wundergraph/[email protected]
id: ff
with:
config_path: .github/cosmo.yaml
destroy: true # Only destroy the feature flag + subgraphs from cosmo.yaml
cosmo_api_key: ${{ secrets.COSMO_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "Feature flag and the feature subgraphs have been destroyed. You can now unprovision the subgraph services."
- run: |
echo "${{ steps.ff.outputs.feature_subgraphs_to_destroy }}"
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Destroy apps on Fly.io
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
run: |
echo '${{ steps.ff.outputs.feature_subgraphs_to_destroy }}' | jq -c '.[]' | while read -r subgraph; do
name=$(echo "$subgraph" | jq -r '.featureSubgraphName')
flyctl apps destroy $name --yes
done