Skip to content

Commit eadbc95

Browse files
committed
Fixes #2: Automatically push all tags to Docker Hub on master commits.
1 parent afd874a commit eadbc95

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

.travis.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ env:
1111
install:
1212
# Install Ansible.
1313
- pip install ansible docker
14+
- export ANSIBLE_FORCE_COLOR=true
1415

1516
# Install role dependencies.
1617
- ansible-galaxy install -r requirements.yml
@@ -24,5 +25,22 @@ script:
2425
- docker exec php-apache php -v | grep ${php_version}
2526
- curl http://localhost:8080/
2627

27-
# notifications:
28-
# webhooks: https://galaxy.ansible.com/api/v1/notifications/
28+
after_success:
29+
- |
30+
if [[ "$TRAVIS_BRANCH" == "master" ]]; then
31+
# Log into Docker Hub.
32+
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
33+
34+
# Push $php_version tag.
35+
docker push geerlingguy/php-apache:${php_version}
36+
37+
# Push $php_version + '.x' tag.
38+
docker tag geerlingguy/php-apache:${php_version} geerlingguy/php-apache:${php_version}.x
39+
geerlingguy/php-apache:${php_version}.x
40+
41+
# Push latest tag if building latest version.
42+
if [[ "$php_version" == "7.2" ]]; then
43+
docker tag geerlingguy/php-apache:${php_version} geerlingguy/php-apache:latest
44+
docker push geerlingguy/php-apache:latest
45+
fi
46+
fi

README.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,7 @@ Then, make sure Docker is running, and run the playbook to build the container:
9494
9595
### Push the image to Docker Hub
9696

97-
Currently, the process for updating this image on Docker Hub is manual. Eventually this will be automated via Travis CI.
98-
99-
1. Log into Docker Hub on the command line:
100-
101-
docker login --username=geerlingguy
102-
103-
1. Tag the latest version (only if this is the latest/default version):
104-
105-
docker tag [image id] geerlingguy/php-apache:latest
106-
107-
1. Tag the PHP major version:
108-
109-
docker tag [image id] geerlingguy/php-apache:7.2 # or 7.1, etc.
110-
docker tag [image id] geerlingguy/php-apache:7.2.5 # the specific version
111-
112-
1. Push tags to Docker Hub:
113-
114-
docker push geerlingguy/php-apache:latest # (if this was just tagged)
115-
docker push geerlingguy/php-apache:7.2 # or 7.1, etc.
116-
docker push geerlingguy/php-apache:7.2.5 # the specific version
97+
See the `.travis.yml` file in this repository for how it pushes all the tagged images automatically on any commit to the `master` branch.
11798

11899
## License
119100

0 commit comments

Comments
 (0)