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: docker push at deploy instead of after_success? #12

Open
junaruga opened this issue Jun 5, 2019 · 0 comments
Open

Travis: docker push at deploy instead of after_success? #12

junaruga opened this issue Jun 5, 2019 · 0 comments

Comments

@junaruga
Copy link
Member

junaruga commented Jun 5, 2019

I found a tip for docker push. This tip can be used for not only multiarch/fedora, but also other multiarch/*.

Right now our .travis.yml's docker push logic is like this.

after_success:
    - |
      if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then
          docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" "$DOCKER_SERVER" && \
              docker push $DOCKER_REPO
      fi

This logic 's challenge is

  • We cat not catch an script failure in the process of after_success. If the error happens in it, the Travis CI still succeeds.

I assume when using deploy: for docker login and docker push, we can catch an error in the deploy, also can write conditional statement like "if branch == master" simply.

https://medium.com/mobileforgood/5-tips-to-optimise-your-travis-ci-file-eced09d2d74e
3. Docker image caching

.travis.yml

before_deploy:
    - echo -n "$REGISTRY_PASS" | docker login -u "$REGISTRY_USER" --password-stdin
deploy:
    provider: script
    script: docker push "$IMAGE_TAG"
    on:
        branch: master

https://docs.travis-ci.com/user/docker/#branch-based-registry-pushes
https://docs.travis-ci.com/user/deployment

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