6
6
- test-ci/**
7
7
push :
8
8
branches :
9
- - ' main'
9
+ - " main"
10
10
- test-ci/**
11
11
tags :
12
12
- v**
21
21
runs-on : ubuntu-latest
22
22
steps :
23
23
- uses : actions/checkout@v4
24
- - uses : actions/setup-python@v4
24
+ - uses : actions/setup-python@v5
25
25
with :
26
- python-version : ' 3.9 '
26
+ python-version : " 3.12 "
27
27
- name : Install dependencies
28
28
run : |
29
29
python -m pip install --upgrade pip
@@ -45,10 +45,10 @@ jobs:
45
45
steps :
46
46
- uses : actions/checkout@v4
47
47
with :
48
- fetch-depth : 0 # This is important for git describe to work correctly
49
- - uses : actions/setup-python@v4
48
+ fetch-depth : 0 # This is important for git describe to work correctly
49
+ - uses : actions/setup-python@v5
50
50
with :
51
- python-version : ' 3.9 '
51
+ python-version : " 3.12 "
52
52
- name : Build connector
53
53
run : |
54
54
cd connector-definition
60
60
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
61
61
- name : Get commit hash
62
62
id : get_commit_hash
63
- run : |
63
+ run : |
64
64
COMMIT_HASH=$(git rev-parse HEAD)
65
65
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
66
66
- name : Debug information
@@ -82,30 +82,83 @@ jobs:
82
82
if : startsWith(github.ref, 'refs/tags/v')
83
83
steps :
84
84
- uses : actions/checkout@v4
85
+
86
+ - name : Set up containerd
87
+ uses : crazy-max/ghaction-setup-containerd@v3
88
+
89
+ - name : Fix containerd socket permissions
90
+ run : |
91
+ sudo chgrp docker /run/containerd/containerd.sock
92
+
85
93
- name : Set up QEMU
86
- uses : docker/setup-qemu-action@v2
94
+ uses : docker/setup-qemu-action@v3
95
+
87
96
- name : Set up Docker Buildx
88
97
uses : docker/setup-buildx-action@v3
98
+
89
99
- name : Login to GitHub Container Registry
90
100
uses : docker/login-action@v3
91
101
with :
92
- registry : ${{ env.DOCKER_REGISTRY }}
93
- username : ${{ github.actor }}
94
- password : ${{ secrets.GITHUB_TOKEN }}
102
+ registry : ${{ env.DOCKER_REGISTRY }}
103
+ username : ${{ github.actor }}
104
+ password : ${{ secrets.GITHUB_TOKEN }}
105
+
95
106
- name : Extract metadata (tags, labels) for Docker
96
107
id : docker-metadata
97
108
uses : docker/metadata-action@v5
98
109
with :
99
- images : ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
100
- - name : Build and push Docker image
101
- uses : docker/build-push-action@v5
110
+ images : ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}
111
+
112
+ - name : Build Docker image
113
+ uses : docker/build-push-action@v6
114
+ with :
115
+ context : .
116
+ push : false
117
+ platforms : linux/amd64,linux/arm64
118
+ tags : ${{ steps.docker-metadata.outputs.tags }}
119
+ labels : ${{ steps.docker-metadata.outputs.labels }}
120
+ # Export the image to a tar so it can be imported into containerd so gokakashi can scan it
121
+ outputs : type=oci,dest=/tmp/image.tar
122
+
123
+ - name : Import docker image into containerd store
124
+ run : |
125
+ ctr images import --base-name ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }} --digests --all-platforms /tmp/image.tar
126
+
127
+ - name : Get first docker tag for gokakashi
128
+ id : first-docker-tag
129
+ run : |
130
+ FIRST_TAG=$(echo "${{ steps.docker-metadata.outputs.tags }}" | head -n 1)
131
+ echo "First docker tag: $FIRST_TAG"
132
+ echo "tag=$FIRST_TAG" >> $GITHUB_OUTPUT
133
+
134
+ - name : Scan docker image with gokakashi
135
+ uses :
shinobistack/[email protected]
136
+ with :
137
+ image : ${{ steps.first-docker-tag.outputs.tag }}
138
+ labels : agentKey=${{ github.run_id }}
139
+ policy : ci-platform
140
+ server : https://gokakashi-server.hasura-app.io
141
+ token : ${{ secrets.GOKAKASHI_API_TOKEN }}
142
+ cf_client_id : ${{ secrets.CF_ACCESS_CLIENT_ID }}
143
+ cf_client_secret : ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
144
+ interval : 10
145
+ retries : 8
146
+
147
+ - name : Upload Trivy report as artifact
148
+ uses : actions/upload-artifact@v4
149
+ with :
150
+ name : trivy-report
151
+ path : /tmp/trivy-report-*.json
152
+
153
+ - name : Push Docker image
154
+ uses : docker/build-push-action@v6
102
155
with :
103
- context : .
104
- push : true
105
- platforms : linux/amd64,linux/arm64
106
- tags : ${{ steps.docker-metadata.outputs.tags }}
107
- labels : ${{ steps.docker-metadata.outputs.labels }}
108
-
156
+ context : .
157
+ push : true
158
+ platforms : linux/amd64,linux/arm64
159
+ tags : ${{ steps.docker-metadata.outputs.tags }}
160
+ labels : ${{ steps.docker-metadata.outputs.labels }}
161
+
109
162
release-connector :
110
163
name : Release connector
111
164
runs-on : ubuntu-latest
@@ -126,11 +179,13 @@ jobs:
126
179
run : |
127
180
echo "tagged_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
128
181
shell : bash
182
+
129
183
- uses : mindsers/changelog-reader-action@v2
130
184
id : changelog-reader
131
185
with :
132
186
version : ${{ steps.get-version.outputs.tagged_version }}
133
187
path : ./CHANGELOG.md
188
+
134
189
- uses : softprops/action-gh-release@v1
135
190
with :
136
191
draft : false
@@ -142,75 +197,76 @@ jobs:
142
197
143
198
- name : Update ndc-hub
144
199
env :
145
- REGISTRY_NAME : hasura
146
- CONNECTOR_NAME : ndc-python-lambda
147
- COMMIT_HASH : ${{ needs.build-connector.outputs.commit_hash }}
148
- SHA256 : ${{ needs.build-connector.outputs.sha256 }}
149
- GH_TOKEN : ${{ secrets.PAT_TOKEN }}
200
+ REGISTRY_NAME : hasura
201
+ CONNECTOR_NAME : ndc-python-lambda
202
+ COMMIT_HASH : ${{ needs.build-connector.outputs.commit_hash }}
203
+ SHA256 : ${{ needs.build-connector.outputs.sha256 }}
204
+ GH_TOKEN : ${{ secrets.PAT_TOKEN }}
150
205
run : |
151
- # Clone ndc-hub repository
152
- git clone https://github.com/hasura/ndc-hub.git
153
- cd ndc-hub
154
-
155
- # Create a new branch
156
- NEW_BRANCH="update-${{ env.CONNECTOR_NAME }}-connector-v${{ steps.get-version.outputs.tagged_version }}"
157
- git checkout -b $NEW_BRANCH
158
-
159
- cd registry/${{ env.REGISTRY_NAME }}/python
160
-
161
- # Create releases directory if it doesn't exist
162
- mkdir -p releases/v${{ steps.get-version.outputs.tagged_version }}
163
-
164
- # Create connector-packaging.json
165
- cat << EOF > releases/v${{ steps.get-version.outputs.tagged_version }}/connector-packaging.json
166
- {
167
- "version": "v${{ steps.get-version.outputs.tagged_version }}",
168
- "uri": "https://github.com/${{ github.repository }}/releases/download/v${{ steps.get-version.outputs.tagged_version }}/connector-definition.tgz",
169
- "checksum": {
170
- "type": "sha256",
171
- "value": "$SHA256"
172
- },
173
- "source": {
174
- "hash": "$COMMIT_HASH"
175
- }
176
- }
177
- EOF
178
-
179
- # Update metadata.json to remove 'packages' field if it exists and update 'latest_version'
180
- jq --arg version_tag "v${{ steps.get-version.outputs.tagged_version }}" \
181
- --arg commit_hash "$COMMIT_HASH" \
182
- 'if has("packages") then del(.packages) else . end |
183
- .overview.latest_version = $version_tag |
184
- if has("source_code") then
185
- .source_code.version += [{
186
- "tag": $version_tag,
187
- "hash": $commit_hash,
188
- "is_verified": false
189
- }]
190
- else
191
- . + {"source_code": {"version": [{
192
- "tag": $version_tag,
193
- "hash": $commit_hash,
194
- "is_verified": false
195
- }]}}
196
- end' \
197
- metadata.json > tmp.json && mv tmp.json metadata.json
198
-
199
- cp ../../../../README.md ./README.md
200
-
201
- # Commit changes
202
- git config user.name "GitHub Action"
203
- git config user.email "[email protected] "
204
- git add metadata.json README.md releases
205
- git commit -m "Update ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}"
206
-
207
- # Push changes
208
- git push https://${{ secrets.PAT_TOKEN }}@github.com/hasura/ndc-hub.git HEAD:$NEW_BRANCH
209
-
210
- # Create PR using GitHub CLI
211
- cd ../..
212
- gh pr create --repo hasura/ndc-hub \
213
- --base main \
214
- --head $NEW_BRANCH \
215
- --title "Update ${{ env.CONNECTOR_NAME }} connector to v${{ steps.get-version.outputs.tagged_version }}" \
216
- --body "This PR updates the ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}."
206
+ # Clone ndc-hub repository
207
+ git clone https://github.com/hasura/ndc-hub.git
208
+ cd ndc-hub
209
+
210
+ # Create a new branch
211
+ NEW_BRANCH="update-${{ env.CONNECTOR_NAME }}-connector-v${{ steps.get-version.outputs.tagged_version }}"
212
+ git checkout -b $NEW_BRANCH
213
+
214
+ cd registry/${{ env.REGISTRY_NAME }}/python
215
+
216
+ # Create releases directory if it doesn't exist
217
+ mkdir -p releases/v${{ steps.get-version.outputs.tagged_version }}
218
+
219
+ # Create connector-packaging.json
220
+ cat << EOF > releases/v${{ steps.get-version.outputs.tagged_version }}/connector-packaging.json
221
+ {
222
+ "version": "v${{ steps.get-version.outputs.tagged_version }}",
223
+ "uri": "https://github.com/${{ github.repository }}/releases/download/v${{ steps.get-version.outputs.tagged_version }}/connector-definition.tgz",
224
+ "checksum": {
225
+ "type": "sha256",
226
+ "value": "$SHA256"
227
+ },
228
+ "source": {
229
+ "hash": "$COMMIT_HASH"
230
+ },
231
+ "test": {
232
+ "test_config_path": "../../tests/test-config.json"
233
+ }
234
+ }
235
+ EOF
236
+
237
+ # Update metadata.json to remove 'packages' field if it exists and update 'latest_version'
238
+ jq --arg version_tag "v${{ steps.get-version.outputs.tagged_version }}" \
239
+ --arg commit_hash "$COMMIT_HASH" \
240
+ 'if has("packages") then del(.packages) else . end |
241
+ .overview.latest_version = $version_tag |
242
+ if has("source_code") then
243
+ .source_code.version += [{
244
+ "tag": $version_tag,
245
+ "hash": $commit_hash,
246
+ "is_verified": false
247
+ }]
248
+ else
249
+ . + {"source_code": {"version": [{
250
+ "tag": $version_tag,
251
+ "hash": $commit_hash,
252
+ "is_verified": false
253
+ }]}}
254
+ end' \
255
+ metadata.json > tmp.json && mv tmp.json metadata.json
256
+
257
+ # Commit changes
258
+ git config user.name "GitHub Action"
259
+ git config user.email "[email protected] "
260
+ git add metadata.json README.md releases
261
+ git commit -m "Update ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}"
262
+
263
+ # Push changes
264
+ git push https://${{ secrets.PAT_TOKEN }}@github.com/hasura/ndc-hub.git HEAD:$NEW_BRANCH
265
+
266
+ # Create PR using GitHub CLI
267
+ cd ../..
268
+ gh pr create --repo hasura/ndc-hub \
269
+ --base main \
270
+ --head $NEW_BRANCH \
271
+ --title "Update ${{ env.CONNECTOR_NAME }} connector to v${{ steps.get-version.outputs.tagged_version }}" \
272
+ --body "This PR updates the ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}."
0 commit comments