-
-
Notifications
You must be signed in to change notification settings - Fork 50
182 lines (176 loc) · 7 KB
/
main.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Default
on:
merge_group:
push:
branches:
- main
pull_request:
types: [ assigned, opened, synchronize, reopened, labeled ]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
Dirty:
runs-on: "formance-runner"
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
- run: >
earthly
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+pre-commit
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42
with:
since_last_remote_commit: true
- name: Run step if test file(s) change
if: steps.changed-files.outputs.all_changed_files == 'true'
run: |
echo "One or more test file(s) has changed."
echo "List all the files that have changed: ${{ steps.changed-files.outputs.all_changed_files }}"
exit 1
Main:
runs-on: "formance-runner"
needs:
- Dirty
steps:
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
--secret FURY_TOKEN=$FURY_TOKEN
--secret GORELEASER_KEY=$GORELEASER_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+pr
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
Extract:
name: Extract
runs-on: "ubuntu-latest"
outputs:
components: ${{ steps.extract.outputs.components }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Extract service name
id: extract
run: echo "components=$(node .github/actions/find-directory/index.js)" >> $GITHUB_OUTPUT
GoReleaser:
runs-on: "ubuntu-latest"
if: contains(github.event.pull_request.labels.*.name, 'build-images') || github.ref == 'refs/heads/main' || github.event_name == 'merge_group'
needs:
- Extract
strategy:
matrix:
components: ${{ fromJson(needs.Extract.outputs.components) }}
steps:
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: "latest"
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "NumaryBot"
password: ${{ secrets.NUMARY_GITHUB_TOKEN }}
- run: >
earthly
--no-output
--allow-privileged
--secret SPEAKEASY_API_KEY=$SPEAKEASY_API_KEY
--secret SEGMENT_WRITE_KEY=$SEGMENT_WRITE_KEY
--secret GITHUB_TOKEN=$GITHUB_TOKEN
--secret FURY_TOKEN=$FURY_TOKEN
--secret GORELEASER_KEY=$GORELEASER_KEY
${{ contains(github.event.pull_request.labels.*.name, 'no-cache') && '--no-cache' || '' }}
+goreleaser --type=${{ matrix.components.type }} --components=${{ matrix.components.component }} --mode=ci
env:
GITHUB_TOKEN: ${{ secrets.NUMARY_GITHUB_TOKEN }}
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY_OSS }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
Deploy:
runs-on: "ubuntu-latest"
if: github.ref == 'refs/heads/main'
environment:
name: staging
permissions:
id-token: write
contents: read
needs:
- GoReleaser
- Main
steps:
- uses: earthly/actions-setup@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: "latest"
- uses: 'actions/checkout@v4'
with:
fetch-depth: 0
- name: Setup Env
uses: ./.github/actions/env
- name: Install and configure kubectl
run: |
VERSION=$(curl --silent https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl https://storage.googleapis.com/kubernetes-release/release/$VERSION/bin/linux/amd64/kubectl \
--progress-bar \
--location \
--remote-name
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::955332203423:role/github-access
aws-region: eu-west-1
output-credentials: true
- name: Update kube config
run: aws eks update-kubeconfig --name staging-eu-west-1-hosting --region eu-west-1
- run: kubectl config use-context arn:aws:eks:eu-west-1:955332203423:cluster/staging-eu-west-1-hosting
- name: Deploy in staging
run: |
kubectl set image deployment -n formance-system agent agent=ghcr.io/formancehq/agent:${GITHUB_SHA}-scratch
kubectl set image deployment -n formance-system operator operator=ghcr.io/formancehq/operator:${GITHUB_SHA}-scratch
kubectl patch Versions default -p "{\"spec\":{\"ledger\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"payments\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"auth\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"gateway\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"orchestration\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"reconciliation\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"search\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"stargate\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"wallets\": \"${GITHUB_SHA}-scratch\"}}" --type=merge
kubectl patch Versions default -p "{\"spec\":{\"webhooks\": \"${GITHUB_SHA}-scratch\"}}" --type=merge