Skip to content

Commit f3558f2

Browse files
committed
1st attempt at artifact promotion
Signed-off-by: Federico Busetti <[email protected]>
1 parent 0275a20 commit f3558f2

File tree

4 files changed

+32
-26
lines changed

4 files changed

+32
-26
lines changed

.gitlab_ci/_templates.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ variables:
4444

4545
- docker manifest push $DOCKER_IMAGE_FULL_TAG
4646

47+
.promote-image:
48+
image: docker:24.0.2
49+
variables:
50+
PROMOTED_ENVIRONMENT: "dev"
51+
DOCKER_BUILDKIT: 1
52+
services:
53+
- docker:24.0.2-dind
54+
script:
55+
- desired_format="%s" # This format will output the Unix timestamp
56+
- export UNIX_TIMESTAMP=$(date -d "$CI_COMMIT_TIMESTAMP" +"$desired_format")
57+
- echo "Unix timestamp: $UNIX_TIMESTAMP"
58+
- docker buildx imagetools create \
59+
--annotation "index:org.opencontainers.image.version=$CI_COMMIT_SHORT_SHA" \
60+
--annotation "index:org.opencontainers.image.revision=$CI_COMMIT_SHA" \
61+
--annotation "index:org.opencontainers.image.source=$CI_PROJECT_URL" \
62+
--annotation "index:org.opencontainers.image.created=$CI_JOB_STARTED_AT" \
63+
--tag $DOCKER_IMAGE_NAME:$PROMOTED_ENVIRONMENT-$UNIX_TIMESTAMP \
64+
- $DOCKER_IMAGE_FULL_TAG
65+
4766
.python-typing:
4867
image: $DOCKER_IMAGE_FULL_TAG
4968
script:

.gitlab_ci/base.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ variables:
88
stages:
99
- build
1010
- test
11-
- release
11+
- deploy
1212

1313
include:
1414
- local: /.gitlab_ci/_templates.yml
1515
- local: /.gitlab_ci/build.yml
1616
- local: /.gitlab_ci/test.yml
17+
- local: /.gitlab_ci/deploy.yml

.gitlab_ci/deploy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
promote-dev:
2+
stage: deploy
3+
variables:
4+
DOCKER_IMAGE_TAG_PREFIX: "http-"
5+
rules:
6+
# We run the pipeline only on merge requests or the `main` branch
7+
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
8+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
9+
extends:
10+
- .build-and-push-gitlab
11+
when: manual

.gitlab_ci/release.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)