1- name : CI Pipeline
1+ name : Build and push to quay
22
33on :
44 pull_request :
5+ branches : [main]
56 push :
67 branches : [main]
78 tags :
8- - " v*"
9+ - " v*.*.* "
910
10- jobs :
11- lint :
12- runs-on : ubuntu-latest
13- steps :
14- - uses : actions/checkout@v4
15- - uses : actions/setup-python@v5
16- with :
17- python-version : " 3.12"
18- - run : pip install black isort ruff
19- - run : black --check .
20- - run : isort --check-only .
21- - run : ruff check .
11+ permissions :
12+ contents : read
13+
14+ env :
15+ REGISTRY : localhost
16+ NAME : vector-embedder
17+ TAG : ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || (github.ref_name == 'main' && 'latest' || github.ref_name) }}
2218
23- build :
19+ jobs :
20+ build-container :
2421 runs-on : ubuntu-latest
25- needs : lint
26- outputs :
27- image_tag : ${{ steps.meta.outputs.sha_tag }}
28- steps :
29- - uses : actions/checkout@v4
3022
31- - name : Generate tag
32- id : meta
33- run : echo "sha_tag=sha-${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
23+ permissions :
24+ contents : read
3425
35- - name : Build Docker image
36- uses : docker/build-push-action@v5
26+ steps :
27+ - name : Checkout code
28+ uses : actions/checkout@v5
3729 with :
38- context : .
39- file : ./Containerfile
40- load : true
41- tags : test-image:${{ steps.meta.outputs.sha_tag }}
30+ fetch-depth : 0
31+ persist-credentials : false
4232
43- - name : Save image as artifact
44- run : docker save test-image:${{ steps.meta.outputs.sha_tag }} -o image.tar
33+ - name : Build container and push to local registry
34+ env :
35+ CONTAINER : ${{ env.NAME }}:${{ env.TAG }}
36+ run : |
37+ make build
38+ podman push "${CONTAINER}" "docker-archive:/tmp/image.tar:${CONTAINER}"
4539
4640 - name : Upload image artifact
4741 uses : actions/upload-artifact@v4
4842 with :
49- name : test-image
50- path : image.tar
43+ name : image-${{ github.run_id }}
44+ path : /tmp/image.tar
45+ retention-days : 1
5146
5247 test :
53- needs : [lint, build]
54- runs-on : ubuntu-latest
48+ needs : [build-container ]
49+ if : github.event_name == 'pull_request'
5550 strategy :
5651 fail-fast : false
5752 matrix :
5853 db : [pgvector, redis, elastic, qdrant, mssql]
5954
55+ runs-on : ubuntu-latest
56+ permissions :
57+ contents : read
58+
6059 steps :
61- - uses : actions/checkout@v4
60+ - name : Checkout code
61+ uses : actions/checkout@v5
62+ with :
63+ fetch-depth : 0
64+ persist-credentials : false
6265
63- - name : Download image artifact
64- uses : actions/download-artifact@v4
66+ - name : Download image
67+ uses : actions/download-artifact@v5
6568 with :
66- name : test- image
67- path : .
69+ name : image-${{ github.run_id }}
70+ path : /tmp
6871
69- - name : Load Docker image
70- run : docker load -i image.tar
72+ - name : Load image into local containers-storage
73+ run : podman pull docker-archive:/tmp/ image.tar
7174
7275 - name : Start MSSQL
7376 if : matrix.db == 'mssql'
7477 run : |
75- docker run -d --name mssql-vector-test \
78+ podman run -d --name mssql-vector-test \
7679 -e "ACCEPT_EULA=Y" \
7780 -e "SA_PASSWORD=StrongPassword!" \
7881 -p 1433:1433 \
8184 - name : Start PGVector
8285 if : matrix.db == 'pgvector'
8386 run : |
84- docker run -d --name pgvector-test \
87+ podman run -d --name pgvector-test \
8588 -e POSTGRES_USER=user \
8689 -e POSTGRES_PASSWORD=pass \
8790 -e POSTGRES_DB=mydb \
@@ -91,14 +94,14 @@ jobs:
9194 - name : Start Redis
9295 if : matrix.db == 'redis'
9396 run : |
94- docker run -d --name redis-test \
97+ podman run -d --name redis-test \
9598 -p 6379:6379 \
9699 redis/redis-stack-server:6.2.6-v19
97100
98101 - name : Start Elasticsearch
99102 if : matrix.db == 'elastic'
100103 run : |
101- docker run -d --name es-test \
104+ podman run -d --name es-test \
102105 -e "discovery.type=single-node" \
103106 -e "xpack.security.enabled=true" \
104107 -e "ELASTIC_PASSWORD=changeme" \
@@ -109,53 +112,86 @@ jobs:
109112 - name : Start Qdrant
110113 if : matrix.db == 'qdrant'
111114 run : |
112- docker run -d --name qdrant-test \
115+ podman run -d --name qdrant-test \
113116 -p 6333:6333 \
114117 qdrant/qdrant
115118
116119 - name : Wait for DB to start
117120 run : sleep 30
118121
119122 - name : Run embed job
123+ env :
124+ CONTAINER : ${{ env.NAME }}:${{ env.TAG }}
125+ DB_TYPE : ${{ matrix.db }}
120126 run : |
121- docker run --rm --network host \
127+ podman run --rm --network host \
122128 -e LOG_LEVEL=debug \
123- -e DB_TYPE=${{ matrix.db }} \
124- test-image:${{ needs.build.outputs.image_tag }}
129+ -e DB_TYPE="${DB_TYPE}" \
130+ "${REGISTRY}/${CONTAINER}"
131+
132+ push-container :
133+ needs : [build-container]
134+ if : github.event_name != 'pull_request'
135+ strategy :
136+ matrix :
137+ include :
138+ - upload_registry : quay.io/validatedpatterns
139+ legacy : false
140+ - upload_registry : quay.io/hybridcloudpatterns
141+ legacy : true
125142
126- release :
127- if : (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && github.event.repository.fork == false
128143 runs-on : ubuntu-latest
129- needs : [lint, build, test]
130- steps :
131- - uses : actions/checkout@v4
144+ permissions :
145+ contents : read
146+ # This is used to complete the identity challenge
147+ # with sigstore/fulcio when running outside of PRs.
148+ id-token : write
132149
133- - name : Log in to Quay.io
134- uses : docker/login-action@v3
150+ steps :
151+ - name : Checkout code
152+ uses : actions/checkout@v5
135153 with :
136- registry : quay.io
137- username : ${{ secrets.QUAY_USERNAME }}
138- password : ${{ secrets.QUAY_PASSWORD }}
154+ fetch-depth : 0
155+ persist-credentials : false
139156
140- - name : Download image artifact
141- uses : actions/download-artifact@v4
157+ - name : Download image
158+ uses : actions/download-artifact@v5
142159 with :
143- name : test- image
144- path : .
160+ name : image-${{ github.run_id }}
161+ path : /tmp
145162
146- - name : Load Docker image
147- run : docker load -i image.tar
163+ - name : Load image into local containers-storage
164+ run : podman pull docker-archive:/tmp/ image.tar
148165
149- - name : Tag and push image
166+ - name : Log into Quay
167+ env :
168+ USERNAME : ${{ matrix.legacy && secrets.LEGACY_QUAY_USERNAME || secrets.QUAY_USERNAME }}
169+ PASSWORD : ${{ matrix.legacy && secrets.LEGACY_QUAY_PASSWORD || secrets.QUAY_PASSWORD }}
150170 run : |
151- docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/hybridcloudpatterns/vector-embedder:${{ needs.build.outputs.image_tag }}
171+ podman login -u "${USERNAME}" -p "${PASSWORD}" quay.io
152172
153- if [[ $GITHUB_REF == refs/tags/* ]]; then
154- docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/hybridcloudpatterns/vector-embedder:${GITHUB_REF#refs/tags/}
155- docker push quay.io/hybridcloudpatterns/vector-embedder:${GITHUB_REF#refs/tags/}
156- elif [[ $GITHUB_REF == refs/heads/main ]]; then
157- docker tag test-image:${{ needs.build.outputs.image_tag }} quay.io/hybridcloudpatterns/vector-embedder:latest
158- docker push quay.io/hybridcloudpatterns/vector-embedder:latest
159- fi
173+ - name : Push image to Quay
174+ id : image-push
175+ env :
176+ UPLOADREGISTRY : ${{ matrix.upload_registry }}
177+ CONTAINER : ${{ env.NAME }}:${{ env.TAG }}
178+ run : |
179+ make upload
180+ DIGEST=$(skopeo inspect --format "{{.Digest}}" "docker://${UPLOADREGISTRY}/${CONTAINER}")
181+ echo "digest=$DIGEST" >> "$GITHUB_OUTPUT"
160182
161- docker push quay.io/hybridcloudpatterns/vector-embedder:${{ needs.build.outputs.image_tag }}
183+ - name : Install cosign
184+ uses : sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
185+ with :
186+ cosign-release : " v2.2.4"
187+
188+ # Cosign expects the docker config.json for registry authentication so we must
189+ # copy it from buildah
190+ - name : Sign the published Docker image
191+ env :
192+ CONTAINER : ${{ env.NAME }}:${{ env.TAG }}
193+ DIGEST : ${{ steps.image-push.outputs.digest }}
194+ UPLOADREGISTRY : ${{ matrix.upload_registry }}
195+ run : |
196+ cat "${XDG_RUNTIME_DIR}/containers/auth.json" > ~/.docker/config.json
197+ cosign sign --yes "${UPLOADREGISTRY}/${CONTAINER}@${DIGEST}"
0 commit comments