-
Notifications
You must be signed in to change notification settings - Fork 4
147 lines (127 loc) · 4.52 KB
/
Copy pathprod-ci-superplane.yml
File metadata and controls
147 lines (127 loc) · 4.52 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: prod-ci-superplane
on:
push:
branches:
- main
permissions:
contents: read
env:
BACKEND_IMAGE: chitsetu-backend
FRONTEND_IMAGE: chitsetu-frontend
ML_IMAGE: chitsetu-ml
WEB3_IMAGE: chitsetu-web3
jobs:
ci-build-push-notify:
runs-on: ubuntu-latest
environment: Chitsetu secrets
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: services/backend/go.mod
- name: Backend checks
working-directory: services/backend
run: |
go test ./...
go build ./...
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: services/frontend/package-lock.json
- name: Frontend checks
working-directory: services/frontend
run: |
npm ci
npm run lint --if-present
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: ML checks
working-directory: services/ml-service
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m compileall app
- name: Set image namespace
shell: bash
run: |
if [ -n "${{ secrets.DOCKERHUB_NAMESPACE }}" ]; then
echo "IMAGE_NAMESPACE=${{ secrets.DOCKERHUB_NAMESPACE }}" >> "$GITHUB_ENV"
else
echo "IMAGE_NAMESPACE=${{ secrets.DOCKERHUB_USERNAME }}" >> "$GITHUB_ENV"
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push backend image
uses: docker/build-push-action@v6
with:
context: services/backend
file: services/backend/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAMESPACE }}/${{ env.BACKEND_IMAGE }}:latest
${{ env.IMAGE_NAMESPACE }}/${{ env.BACKEND_IMAGE }}:${{ github.sha }}
- name: Build and push frontend image
uses: docker/build-push-action@v6
with:
context: services/frontend
file: services/frontend/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAMESPACE }}/${{ env.FRONTEND_IMAGE }}:latest
${{ env.IMAGE_NAMESPACE }}/${{ env.FRONTEND_IMAGE }}:${{ github.sha }}
- name: Build and push ml image
uses: docker/build-push-action@v6
with:
context: services/ml-service
file: services/ml-service/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAMESPACE }}/${{ env.ML_IMAGE }}:latest
${{ env.IMAGE_NAMESPACE }}/${{ env.ML_IMAGE }}:${{ github.sha }}
- name: Build and push web3 image
uses: docker/build-push-action@v6
with:
context: services/web3
file: services/web3/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAMESPACE }}/${{ env.WEB3_IMAGE }}:latest
${{ env.IMAGE_NAMESPACE }}/${{ env.WEB3_IMAGE }}:${{ github.sha }}
- name: Trigger SuperPlane webhook
shell: bash
env:
SUPERPLANE_WEBHOOK_URL: ${{ secrets.SUPERPLANE_WEBHOOK_URL }}
SUPERPLANE_TOKEN: ${{ secrets.SUPERPLANE_TOKEN }}
run: |
payload=$(cat <<JSON
{
"event": "build.success",
"sha": "${{ github.sha }}",
"branch": "${{ github.ref_name }}",
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"images": {
"backend": "${{ env.IMAGE_NAMESPACE }}/${{ env.BACKEND_IMAGE }}:${{ github.sha }}",
"frontend": "${{ env.IMAGE_NAMESPACE }}/${{ env.FRONTEND_IMAGE }}:${{ github.sha }}",
"ml": "${{ env.IMAGE_NAMESPACE }}/${{ env.ML_IMAGE }}:${{ github.sha }}",
"web3": "${{ env.IMAGE_NAMESPACE }}/${{ env.WEB3_IMAGE }}:${{ github.sha }}"
}
}
JSON
)
SIGNATURE=$(echo -n "$payload" | openssl dgst -sha256 -hmac "$SUPERPLANE_TOKEN" -binary | xxd -p -c 256)
curl -X POST "$SUPERPLANE_WEBHOOK_URL" \
-H "X-Signature-256: sha256=$SIGNATURE" \
-H "Content-Type: application/json" \
--data-binary "$payload"