Skip to content

Commit

Permalink
ci: move docker image publishing to github
Browse files Browse the repository at this point in the history
Closes #8330
  • Loading branch information
lidel committed Sep 28, 2021
1 parent 731b4de commit 2837410
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Docker image

on:
workflow_dispatch:
push:
branches:
- 'master'
- 'bifrost-*'
tags:
- 'v*'

jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
env:
IMAGE_NAME: ipfs/go-ipfs
WIP_IMAGE_TAG: wip
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Build wip Docker image
run: docker build -t $IMAGE_NAME:$WIP_IMAGE_TAG .

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Publish Docker Image to Docker Hub
run: ./bin/push-docker-tags.sh $(date -u +%F)

12 changes: 6 additions & 6 deletions bin/push-docker-tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@
#
set -euo pipefail

if [[ $# -lt 3 ]] ; then
echo 'At least 3 args required. Pass 5 args for a dry run.'
if [[ $# -lt 1 ]] ; then
echo 'At least 1 arg required. Pass 5 args for a dry run.'
echo 'Usage:'
echo './push-docker-tags.sh <build number> <git commit sha1> <git branch name> [git tag name] [dry run]'
echo './push-docker-tags.sh <build number> [git commit sha1] [git branch name] [git tag name] [dry run]'
exit 1
fi

BUILD_NUM=$1
GIT_SHA1=$2
GIT_SHA1=${2:-$(git rev-parse HEAD)}
GIT_SHA1_SHORT=$(echo "$GIT_SHA1" | cut -c 1-7)
GIT_BRANCH=$3
GIT_TAG=${4:-""}
GIT_BRANCH=${3:-$(git symbolic-ref -q --short HEAD || echo "unknown")}
GIT_TAG=${4:-$(git describe --tags --exact-match || echo "")}
DRY_RUN=${5:-false}

WIP_IMAGE_TAG=${WIP_IMAGE_TAG:-wip}
Expand Down

0 comments on commit 2837410

Please sign in to comment.