@cryptotaxi247 / kubo / commits / c0f282f00

ci: move Docker image build to Actions (#8467)

* ci: move docker image publishing to github Closes #8330 * chore: remove dockerhub push from circleci

Marcin Rataj committed Sep 28, 2021 at 22:30 UTC c0f282f00fa7d94f0c2a9e3caba840841ef3728c
3 files changed +42 -100
.circleci/main.yml
+2 -94
@@ -24,11 +24,6 @@ aliases:
24 paths:
25 - ~/go/pkg/mod
26 - ~/.cache/go-build/
27 - only-version-tags: &only-version-tags
28 - tags:
29 - only: /^v[0-9].*/
30 - branches:
31 - ignore: /.*/
27
28 default_environment: &default_environment
29 SERVICE: circle-ci
@@ -331,6 +326,8 @@ jobs:
326 key: v1-ipfs-webui-{{ checksum "~/ipfs/go-ipfs/ipfs-webui/package-lock.json" }}
327 paths:
328 - ~/ipfs/go-ipfs/ipfs-webui/node_modules
329 + # We only run build as a test here. DockerHub images are built and published
330 + # by Github Action now: https://github.com/ipfs/go-ipfs/pull/8467
331 docker-build:
332 executor: dockerizer
333 steps:
@@ -341,62 +338,6 @@ jobs:
338 name: Build Docker image
339 command: |
340 docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG .
344 - - run:
345 - name: Archive Docker image
346 - command: docker save -o go-ipfs-image.tar $IMAGE_NAME
347 - - persist_to_workspace:
348 - root: .
349 - paths:
350 - - ./go-ipfs-image.tar
351 - docker-build-extras:
352 - executor: dockerizer
353 - steps:
354 - - checkout
355 - - setup_remote_docker:
356 - version: "19.03.13"
357 - - run:
358 - name: Build Docker Extras image
359 - command: |
360 - docker build --build-arg IPFS_PLUGINS="peerlog" -t "$IMAGE_NAME-extras:$WIP_IMAGE_TAG" .
361 - - run:
362 - name: Archive Docker Extras image
363 - command: docker save -o go-ipfs-extras-image.tar $IMAGE_NAME
364 - - persist_to_workspace:
365 - root: .
366 - paths:
367 - - ./go-ipfs-extras-image.tar
368 - docker-push:
369 - executor: dockerizer
370 - steps:
371 - - checkout
372 - - setup_remote_docker:
373 - version: "19.03.13"
374 - - attach_workspace:
375 - at: /tmp/workspace
376 - - run:
377 - name: Load archived Docker image
378 - command: docker load -i /tmp/workspace/go-ipfs-image.tar
379 - - run:
380 - name: Publish Docker Image to Docker Hub
381 - command: |
382 - echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
383 - ./bin/push-docker-tags.sh $(date -u +%F) "$CIRCLE_SHA1" "$CIRCLE_BRANCH" "$CIRCLE_TAG"
384 - docker-push-extras:
385 - executor: dockerizer
386 - steps:
387 - - checkout
388 - - setup_remote_docker:
389 - version: "19.03.13"
390 - - attach_workspace:
391 - at: /tmp/workspace
392 - - run:
393 - name: Load archived Docker Extras image
394 - command: docker load -i /tmp/workspace/go-ipfs-extras-image.tar
395 - - run:
396 - name: Publish Docker Extras Image to Docker Hub
397 - command: |
398 - echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
399 - ./bin/push-docker-tags.sh $(date -u +%F) "$CIRCLE_SHA1" "$CIRCLE_BRANCH" "extras"
341
342 workflows:
343 version: 2
@@ -423,36 +364,3 @@ workflows:
364 requires:
365 - build
366 - docker-build
426 - - docker-push:
427 - # Requires dockerhub credentials, from circleci context.
428 - context: dockerhub
429 - requires:
430 - - docker-build
431 - - golint
432 - - gotest
433 - - sharness
434 - - interop
435 - - go-ipfs-api
436 - - go-ipfs-http-client
437 - - ipfs-webui
438 - filters:
439 - branches:
440 - only:
441 - - master
442 - # the bifrost-* branches are used for deploying code that hasn't hit master yet (e.g. for testing)
443 - - /^bifrost-.*/
444 -
445 -
446 - # NOTE: CircleCI only builds tags if you explicitly filter for them. That
447 - # also means tag-based jobs can only depend on other tag-based jobs, so we
448 - # use a separate workflow because every job needs to be tagged together.
449 - # see: https://circleci.com/docs/2.0/workflows/#executing-workflows-for-a-git-tag
450 - docker-on-tag:
451 - jobs:
452 - - docker-build:
453 - filters: *only-version-tags
454 - - docker-push:
455 - context: dockerhub
456 - filters: *only-version-tags
457 - requires:
458 - - docker-build
.github/workflows/docker-image.yml new
+34
@@ -0,0 +1,34 @@
1 +name: Publish Docker image
2 +
3 +on:
4 + workflow_dispatch:
5 + push:
6 + branches:
7 + - 'master'
8 + - 'bifrost-*'
9 + tags:
10 + - 'v*'
11 +
12 +jobs:
13 + push_to_registry:
14 + name: Push Docker image to Docker Hub
15 + runs-on: ubuntu-latest
16 + env:
17 + IMAGE_NAME: ipfs/go-ipfs
18 + WIP_IMAGE_TAG: wip
19 + steps:
20 + - name: Check out the repo
21 + uses: actions/checkout@v2
22 +
23 + - name: Build wip Docker image
24 + run: docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG .
25 +
26 + - name: Log in to Docker Hub
27 + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
28 + with:
29 + username: ${{ secrets.DOCKER_USERNAME }}
30 + password: ${{ secrets.DOCKER_PASSWORD }}
31 +
32 + - name: Publish Docker Image to Docker Hub
33 + run: ./bin/push-docker-tags.sh $(date -u +%F)
34 +
bin/push-docker-tags.sh
+6 -6
@@ -29,18 +29,18 @@
29 #
30 set -euo pipefail
31
32 -if [[ $# -lt 3 ]] ; then
33 - echo 'At least 3 args required. Pass 5 args for a dry run.'
32 +if [[ $# -lt 1 ]] ; then
33 + echo 'At least 1 arg required. Pass 5 args for a dry run.'
34 echo 'Usage:'
35 - echo './push-docker-tags.sh <build number> <git commit sha1> <git branch name> [git tag name] [dry run]'
35 + echo './push-docker-tags.sh <build number> [git commit sha1] [git branch name] [git tag name] [dry run]'
36 exit 1
37 fi
38
39 BUILD_NUM=$1
40 -GIT_SHA1=$2
40 +GIT_SHA1=${2:-$(git rev-parse HEAD)}
41 GIT_SHA1_SHORT=$(echo "$GIT_SHA1" | cut -c 1-7)
42 -GIT_BRANCH=$3
43 -GIT_TAG=${4:-""}
42 +GIT_BRANCH=${3:-$(git symbolic-ref -q --short HEAD || echo "unknown")}
43 +GIT_TAG=${4:-$(git describe --tags --exact-match || echo "")}
44 DRY_RUN=${5:-false}
45
46 WIP_IMAGE_TAG=${WIP_IMAGE_TAG:-wip}