Skip to content

Commit b9f6e19

Browse files
committed
Add image publishing jobs
1 parent c9da783 commit b9f6e19

File tree

2 files changed

+50
-28
lines changed

2 files changed

+50
-28
lines changed

.circleci/config.yml

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ workflows:
88
jobs:
99
- prepare-agents:
1010
context: org-global
11-
# These are scratch images with a single binary (this is scanned on creation by execution) so I think we can do without scanning?
12-
# - scan-image:
13-
# context: org-global
14-
# requires:
15-
# - prepare-agents
1611
- build-and-publish-images:
1712
name: build-and-publish-image-amd64
1813
context: org-global
@@ -25,18 +20,15 @@ workflows:
2520
context: org-global
2621
requires:
2722
- prepare-agents
28-
29-
executors:
30-
ccc:
31-
docker:
32-
- image: circleci/command-convenience:0.1
33-
auth:
34-
username: $DOCKER_HUB_USER
35-
password: $DOCKER_HUB_PASSWORD
36-
environment:
37-
NAME: << pipeline.parameters.release-name >>
38-
DOCKERFILE_PATH: Dockerfile
39-
TEAM: on-prem
23+
- publish-manifest:
24+
context: org-global
25+
filters:
26+
branches:
27+
only:
28+
- main
29+
requires:
30+
- build-and-publish-image-amd64
31+
- build-and-publish-image-arm64
4032

4133
parameters:
4234
release-name:
@@ -76,21 +68,21 @@ jobs:
7668
at: .
7769
- docker_login
7870
- run: ./do build-docker-images << pipeline.parameters.release-name >> << parameters.arch >>
79-
# TODO: Publish images (on main) once the repo is set up
71+
- when:
72+
condition:
73+
equal: [ main, << pipeline.git.branch >> ]
74+
steps:
75+
- run: ./do publish-docker-images << pipeline.parameters.release-name >> << parameters.arch >>
8076
- notify_failing_main
8177

82-
scan-image:
83-
executor: ccc
78+
publish-manifest:
79+
machine:
80+
image: ubuntu-2204:2024.02.7
81+
resource_class: small
8482
steps:
8583
- checkout
86-
- setup_remote_docker
87-
- attach_workspace:
88-
at: .
89-
- run:
90-
name: Scan Docker images
91-
command: scan
92-
- store_artifacts:
93-
path: ccc-image-scan-results
84+
- docker_login
85+
- run: ./do publish-docker-manifest << pipeline.parameters.release-name >>
9486
- notify_failing_main
9587

9688
commands:

do

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,36 @@ build-docker-images() {
3333
docker build -t circleci/"$repo":test-agent-"$arch" --build-arg ARCH="$arch" -f ./runner-init/fake-agent.Dockerfile .
3434
}
3535

36+
# This variable is used, but shellcheck can't tell.
37+
# shellcheck disable=SC2034
38+
help_publish_docker_images="Publish the runner init images"
39+
publish-docker-images() {
40+
repo=${1:?'image repo name must be specified'}
41+
arch=${2:?'image arch must be specified'}
42+
43+
docker push circleci/"$repo":agent-"$arch"
44+
docker push circleci/"$repo":test-agent-"$arch"
45+
}
46+
47+
# This variable is used, but shellcheck can't tell.
48+
# shellcheck disable=SC2034
49+
help_publish_docker_manifest="Publish the mutliarch manifest"
50+
publish-docker-manifest() {
51+
repo=${1:?'image repo name must be specified'}
52+
53+
docker manifest create circleci/runner-init:agent \
54+
--amend circleci/runner-init:agent-amd64 \
55+
--amend circleci/runner-init:agent-arm64
56+
57+
docker manifest push circleci/runner-init:agent
58+
59+
docker manifest create circleci/runner-init:test-agent \
60+
--amend circleci/runner-init:test-agent-amd64 \
61+
--amend circleci/runner-init:test-agent-arm64
62+
63+
docker manifest push circleci/runner-init:test-agent
64+
}
65+
3666
help-text-intro() {
3767
echo "
3868
DO

0 commit comments

Comments
 (0)