Skip to content
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

travis: add a travis-ci entry point for uploading to hepsw docker hub #26

Open
kreczko opened this issue Nov 8, 2017 · 0 comments
Open

Comments

@kreczko
Copy link
Collaborator

kreczko commented Nov 8, 2017

This issue comes in two steps.
Firstly, it is important to change the current travis setup to a build-matrix, e.g. add

env:
  - IMAGE=cvmfs-base BUILD=build UPLOAD=upload
  - IMAGE=cvmfs-base-cc7 BUILD=build-cc7 UPLOAD=upload-cc7
  - ...

script:
  - cd $IMAGE
  - make $BUILD

This allows fine-grained testing on a per-image basis.

The second part is to define what will happen after a successful build:

after_success:
 - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
 - cd $IMAGE
 - make $UPLOAD

The mentioned docker details for https://hub.docker.com/u/hepsw/ need to be added in an encrypted form as shown in https://sebest.github.io/post/using-travis-ci-to-build-docker-images/.
The downside is that the upload will not work for PRs from forks but only for tagged or master builds (i.e. after the merge).

Travis also recommends to create two sets of scripts as secrets won't be available to PRs from forks:

after_success:
   - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./travis/run_on_pull_requests; fi'
   - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./travis/run_on_non_pull_requests; fi'

This means all the above would come together as

sudo: required

services:
  - docker

env:
  global:
    - secure: "UkF2CHX0lUZ...VI/LE=" # DOCKER_EMAIL
    - secure: "Z3fdBNPt5hR...VI/LE=" # DOCKER_USER
    - secure: "F4XbD6WybHC...VI/LE=" # DOCKER_PASS
  matrix:
    - IMAGE=cvmfs-base BUILD=build UPLOAD=upload
    - IMAGE=cvmfs-base-cc7 BUILD=build-cc7 UPLOAD=upload-cc7
    - ...

script:
  - cd $IMAGE
  - make $BUILD

after_success:
   - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./travis/no_upload; fi'
   - 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash ./travis/upload_stuff; fi'

with ./travis/no_upload

#!/usr/bin/env bash
echo "No upload"

and ./travis/upload_stuff

#!/usr/bin/env bash
echo "Pushing $IMAGE to docker hub"
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
cd $IMAGE
make $UPLOAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant