-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: docker build and tag from ci #6949
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
58c2400
feat: docker build and tag from ci
olizilla 80a7f1f
chore: remove unused code
olizilla 8ff47e5
chore: fix yaml indenting
olizilla 7c593bd
wip: add branch filter
olizilla 793f39d
fix: yaml indenting
olizilla 107bbc6
feat: add bifrost-latest docker tag
olizilla cba7be0
chore: fix typo
olizilla e83862a
docs: better explanation of circleci opt-in to tags madness
olizilla 37dcb2d
wip: circle context. filter to relevent branches
olizilla ed9a7e4
Merge remote-tracking branch 'origin/master' into docker-tag-from-ci
olizilla 2ed3662
wip: use date instead of circleci build num
olizilla 358b7fe
fix: pass date to push-docker-tags.sh
olizilla 9f6349b
wip: remove dry run
olizilla 427557e
wip: remove release tag. use more recent docker.
olizilla ec220dd
wip: set IMAGE_NAME: ipfs/go-ipfs
olizilla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
|
||
# push-docker-tags.sh | ||
# | ||
# Run from ci to tag images based on the current branch or tag name. | ||
# A bit like dockerhub autobuild config, but somewhere we can version control it. | ||
# | ||
# The `docker-build` job in .circleci/config.yml builds the current commit | ||
# in docker and tags it as ipfs/go-ipfs:wip | ||
# | ||
# Then the `docker-publish` job runs this script to decide what tag, if any, | ||
# to publish to dockerhub. | ||
# | ||
# Usage: | ||
# ./push-docker-tags.sh <build number> <git commit sha1> <git branch name> [git tag name] [dry run] | ||
# | ||
# Example: | ||
# # dry run. pass a 5th arg to have it print what it would do rather than do it. | ||
# ./push-docker-tags.sh $(date -u +%F) testingsha master "" dryrun | ||
# | ||
# # push tag for the master branch | ||
# ./push-docker-tags.sh $(date -u +%F) testingsha master | ||
# | ||
# # push tag for a release tag | ||
# ./push-docker-tags.sh $(date -u +%F) testingsha release v0.5.0 | ||
# | ||
# # Serving suggestion in circle ci - https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables | ||
# ./push-docker-tags.sh $(date -u +%F) "$CIRCLE_SHA1" "$CIRCLE_BRANCH" "$CIRCLE_TAG" | ||
# | ||
set -euo pipefail | ||
|
||
if [[ $# -lt 3 ]] ; then | ||
echo 'At least 3 args 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]' | ||
exit 1 | ||
fi | ||
|
||
BUILD_NUM=$1 | ||
GIT_SHA1=$2 | ||
GIT_SHA1_SHORT=$(echo "$GIT_SHA1" | cut -c 1-7) | ||
GIT_BRANCH=$3 | ||
GIT_TAG=${4:-""} | ||
DRY_RUN=${5:-false} | ||
|
||
WIP_IMAGE_TAG=${WIP_IMAGE_TAG:-wip} | ||
IMAGE_NAME=${IMAGE_NAME:-ipfs/go-ipfs} | ||
|
||
pushTag () { | ||
local IMAGE_TAG=$1 | ||
if [ "$DRY_RUN" != false ]; then | ||
echo "DRY RUN! I would have tagged and pushed the following..." | ||
echo docker tag "$IMAGE_NAME:$WIP_IMAGE_TAG" "$IMAGE_NAME:$IMAGE_TAG" | ||
echo docker push "$IMAGE_NAME:$IMAGE_TAG" | ||
else | ||
echo "Tagging $IMAGE_NAME:$IMAGE_TAG and pushing to dockerhub" | ||
docker tag "$IMAGE_NAME:$WIP_IMAGE_TAG" "$IMAGE_NAME:$IMAGE_TAG" | ||
docker push "$IMAGE_NAME:$IMAGE_TAG" | ||
fi | ||
} | ||
|
||
if [[ $GIT_TAG =~ ^v[0-9]+ ]]; then | ||
pushTag "$GIT_TAG" | ||
pushTag "latest" | ||
|
||
elif [ "$GIT_BRANCH" = "feat/stabilize-dht" ]; then | ||
pushTag "bifrost-${BUILD_NUM}-${GIT_SHA1_SHORT}" | ||
pushTag "bifrost-latest" | ||
|
||
elif [ "$GIT_BRANCH" = "master" ]; then | ||
pushTag "master-${BUILD_NUM}-${GIT_SHA1_SHORT}" | ||
pushTag "master-latest" | ||
|
||
else | ||
echo "Nothing to do. No docker tag defined for branch: $GIT_BRANCH, tag: $GIT_TAG" | ||
|
||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When are these credentials provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every branch, it looks like? That's not a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep running into this same wall. 🤦♂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolution: only users in a specific group will get this token. That will also be the group with release permissions.