<p>If you're married to Docker Hub, you could use a <a href="https://docs.docker.com/docker-hub/webhooks/" rel="nofollow noreferrer">webhook</a> to <a href="https://docs.travis-ci.com/user/triggering-builds" rel="nofollow noreferrer">notify Travis</a> of the need to start it's job.</p>

<p>However, I solve this problem using Quay.io - it has the <a href="https://docs.quay.io/glossary/robot-accounts.html" rel="nofollow noreferrer">robot account</a> (you refer to "service account") you need. It also has a richer set of <a href="https://docs.quay.io/guides/notifications.html" rel="nofollow noreferrer">notifications</a>.</p>

<p>You could maintain your current workflow using webhooks to </p>

<ol>
<li>create the repository on Quay or Docker Hub, have the image built on git events.</li>
<li>Create a webhook in the repository to send data to your Travis job when builds succeed</li>
</ol>

<p>Or, you could build your images in the Travis job.</p>

<ol>
<li>Push the initial image to a repository on Quay</li>
<li>Add a robot account to your repository in Quay</li>
<li>Add the necessary secrets to your Travis build (token and robot user name)</li>
<li>Configure Travis to build the image, run whatever tests you need and then push on green.</li>
<li>Add an <code>after_success</code> task to redeploy your app in k8s after the push.</li>
</ol>

CC BY-SA 4.0
2018-11-25T08:19:41.273Z
2018-11-25T08:19:41.273Z
Bruce Becker
<p>I'm wanting to create a basic 'on new commits to master, rebuild the images and deploy to kubernetes' pipeline. </p>

<p>Docker Hub has its concept of automated builds on new commits, but I'd still need to use Travis CI to do the kubernetes deployment. </p>

<p>Is there a way to synchronise these - so that Travis doesn't start its scripts until Docker Hub has built the image? </p>

<p>Alternatively - I could just do all of the building on Travis CI. But Docker Hub doesn't seem to provide service accounts - or have I got that wrong? It seems like the only way to create a service account is to actually manually create a new username/password for service account. Is that the case? </p>

<p>What are the generally established ways of doing this? </p>

CC BY-SA 4.0
2019-06-26T04:00:50.933Z
I may not have a clear understanding of the question, but why not just use a deployment script to build the images, push them and apply them to kubernetes? And via a `.travis.yml` file you can tell Travis not to run the deployment script unless you are pushing it to master.
Daniel
<travis-ci><dockerhub>
Docker Hub automated builds and Travis CI
dwjohnston
# Docker Hub automated builds and Travis CI

(Asked by: username_0 on 2018-11-16)

I'm wanting to create a basic 'on new commits to master, rebuild the images and deploy to kubernetes' pipeline.

Docker Hub has its concept of automated builds on new commits, but I'd still need to use Travis CI to do the kubernetes deployment.

Is there a way to synchronise these - so that Travis doesn't start its scripts until Docker Hub has built the image?

Alternatively - I could just do all of the building on Travis CI. But Docker Hub doesn't seem to provide service accounts - or have I got that wrong? It seems like the only way to create a service account is to actually manually create a new username/password for service account. Is that the case?

What are the generally established ways of doing this?

**Tags:** travis-ci, dockerhub

> **Comments:**
> **username_1**: I may not have a clear understanding of the question, but why not just use a deployment script to build the images, push them and apply them to kubernetes? And via a `.travis.yml` file you can tell Travis not to run the deployment script unless you are pushing it to master.  

---

## 1 answers

### Answer by username_2 on 2018-11-25. Score: 1

If you're married to Docker Hub, you could use a [webhook](https://docs.docker.com/docker-hub/webhooks/) to [notify Travis](https://docs.travis-ci.com/user/triggering-builds) of the need to start it's job.

However, I solve this problem using Quay.io - it has the [robot account](https://docs.quay.io/glossary/robot-accounts.html) (you refer to "service account") you need. It also has a richer set of [notifications](https://docs.quay.io/guides/notifications.html).

You could maintain your current workflow using webhooks to

1. create the repository on Quay or Docker Hub, have the image built on git events.
2. Create a webhook in the repository to send data to your Travis job when builds succeed

Or, you could build your images in the Travis job.

1. Push the initial image to a repository on Quay
2. Add a robot account to your repository in Quay
3. Add the necessary secrets to your Travis build (token and robot user name)
4. Configure Travis to build the image, run whatever tests you need and then push on green.
5. Add an `after_success` task to redeploy your app in k8s after the push.


---

