Skip to content

Commit f701cbe

Browse files
Merge pull request #72 from code0-tech/feat/pipeline-improvement
improve pipeline
2 parents 70a79f5 + 3aaa23b commit f701cbe

1 file changed

Lines changed: 56 additions & 2 deletions

File tree

.gitlab-ci.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
stages:
22
- test
33
- build
4+
- manifest
45

56
include:
67
- project: code0-tech/development/telescopium
@@ -49,12 +50,65 @@ build-docker:
4950
- .dind
5051
image: docker:29.4.1
5152
stage: build
53+
tags:
54+
- c0-$PLATFORM
5255
parallel:
5356
matrix:
5457
- C0_ACTION: !reference [.node-actions]
58+
PLATFORM: [amd64, arm64]
5559
- C0_ACTION: !reference [.rust-actions]
60+
PLATFORM: [amd64, arm64]
61+
before_script:
62+
- echo $C0_GH_TOKEN | docker login -u $ --password-stdin ghcr.io
63+
- docker context create build-context
64+
- docker buildx create --name container-builder --driver docker-container --bootstrap --use build-context
5665
script:
5766
- cd actions/$C0_ACTION
67+
- CACHE_TO=""
68+
- |
69+
if [ "$CI_COMMIT_BRANCH" = "main" ]; then
70+
CACHE_TO="--cache-to type=registry,ref=ghcr.io/code0-tech/centaurus/ci-cache:$C0_ACTION-$PLATFORM,mode=max"
71+
fi
72+
- >
73+
docker buildx build
74+
-t ghcr.io/code0-tech/centaurus/ci-builds/$C0_ACTION
75+
--output type=registry,push-by-digest=true
76+
--metadata-file manifest-${CI_JOB_ID}.json
77+
--cache-from type=registry,ref=ghcr.io/code0-tech/centaurus/ci-cache:$C0_ACTION-$PLATFORM
78+
$CACHE_TO
79+
.
80+
artifacts:
81+
paths:
82+
- actions/$C0_ACTION/manifest-*.json
83+
expire_in: 1 day
84+
85+
manifest-docker:
86+
extends:
87+
- .dind
88+
image: docker:29.4.1
89+
stage: manifest
90+
tags:
91+
- c0-amd64
92+
parallel:
93+
matrix:
94+
- C0_ACTION: !reference [.node-actions]
95+
- C0_ACTION: !reference [.rust-actions]
96+
needs:
97+
- job: build-docker
98+
parallel:
99+
matrix:
100+
- C0_ACTION: [ '$[[ matrix.C0_ACTION ]]' ]
101+
PLATFORM: [amd64, arm64]
102+
before_script:
103+
- apk add --no-cache jq
58104
- echo $C0_GH_TOKEN | docker login -u $ --password-stdin ghcr.io
59-
- docker build -t ghcr.io/code0-tech/centaurus/ci-builds/$C0_ACTION:0.0.0-experimental-$CI_PIPELINE_ID-$CI_COMMIT_SHA .
60-
- docker push ghcr.io/code0-tech/centaurus/ci-builds/$C0_ACTION:0.0.0-experimental-$CI_PIPELINE_ID-$CI_COMMIT_SHA
105+
script:
106+
- cd actions/$C0_ACTION
107+
- |
108+
refs=""
109+
for manifest in manifest-*.json; do
110+
name=$(jq -r '."image.name"' "$manifest")
111+
digest=$(jq -r '."containerimage.digest"' "$manifest")
112+
refs="$refs $name@$digest"
113+
done
114+
docker buildx imagetools create -t "ghcr.io/code0-tech/centaurus/ci-builds/$C0_ACTION:0.0.0-experimental-$CI_PIPELINE_ID-$CI_COMMIT_SHA" $refs

0 commit comments

Comments
 (0)