Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
[circleci] Add dockerhub auth env vars to CI (#2559)
Browse files Browse the repository at this point in the history
Add in the org docker username / password and a login command to
release-publishing CI jobs
  • Loading branch information
nataliejameson authored Nov 10, 2020
1 parent ae2347e commit 3ba8a81
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ windows_environment: &windows_environment
BUCK_NUM_THREADS: 3
BUCK_PEX_LOCATION: "./new_buck.pex"

dockerhub: &dockerhub
context:
- DOCKERHUB_TOKEN

tags_only_filter: &tags_only_filter
filters:
tags:
Expand Down Expand Up @@ -1639,11 +1643,11 @@ workflows:
publish_jobs:
jobs:
- macos_publish_release:
<<: *tags_only_filter
<<: [*tags_only_filter, *dockerhub]
- linux_publish_release:
<<: *tags_only_filter
<<: [*tags_only_filter, *dockerhub]
- windows_publish_release:
<<: *tags_only_filter
<<: [*tags_only_filter, *dockerhub]
- publish_docs:
requires:
- linux_publish_release
Expand Down
18 changes: 18 additions & 0 deletions tools/release/publish_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ def parse_args(args):
"https://github.com/chocolatey/chocolatey.org/issues/584"
),
)
parser.add_argument(
"--docker-login",
action="store_true",
help="If set, run 'docker login' using DOCKERHUB_USERNAME and DOCKERHUB_TOKEN",
)
parsed_kwargs = dict(parser.parse_args(args)._get_kwargs())
if parsed_kwargs["deb_file"]:
parsed_kwargs["build_deb"] = False
Expand Down Expand Up @@ -283,6 +288,15 @@ def validate_repo_upstream(args):
)


def docker_login():
username = os.environ.get("DOCKERHUB_USERNAME")
token = os.environ.get("DOCKERHUB_TOKEN")
if username and token:
run(["docker", "login", "--username", username, "--password-stdin"], input=token)
else:
logging.error("Both DOCKERHUB_USERNAME and DOCKERHUB_TOKEN must be set to login to dockerhub")


def validate_environment(args):
""" Make sure we can build """

Expand Down Expand Up @@ -410,6 +424,10 @@ def main():
github_token = (
args.github_token if args.github_token else get_token(args.github_token_file)
)

if args.docker_login:
docker_login()

if args.chocolatey_publish:
chocolatey_token = (
args.chocolatey_token
Expand Down

0 comments on commit 3ba8a81

Please sign in to comment.