Skip to content

Commit 38e745c

Browse files
committed
Switch from Travis CI to GitHub Actions.
1 parent b917a04 commit 38e745c

File tree

4 files changed

+110
-57
lines changed

4 files changed

+110
-57
lines changed

.github/workflows/build.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
name: Build
3+
4+
on:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
schedule:
10+
- cron: "45 1 * * 0"
11+
12+
env:
13+
ANSIBLE_FORCE_COLOR: true
14+
15+
jobs:
16+
# Test the images build and work correctly.
17+
test:
18+
name: Test
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
php_version:
23+
- '7.4'
24+
- '7.3'
25+
- '7.2'
26+
- '7.1'
27+
28+
steps:
29+
- uses: actions/checkout@v2
30+
31+
- name: Set up Python 3.
32+
uses: actions/setup-python@v2
33+
with:
34+
python-version: '3.x'
35+
36+
- name: Install prerequisites.
37+
run: pip3 install ansible docker
38+
39+
- name: Install role dependencies.
40+
run: ansible-galaxy install -r requirements.yml
41+
42+
- name: Build the container.
43+
run: ansible-playbook --extra-vars="@vars/${{ matrix.php_version }}.yml" main.yml
44+
45+
- name: Run the container.
46+
run: docker run -d --name=php-apache -p 8080:80 geerlingguy/php-apache:${{ matrix.php_version }} /usr/sbin/apache2ctl -D FOREGROUND
47+
48+
- name: Verify container has correct PHP version and works.
49+
run: |
50+
docker exec php-apache php -v | grep ${{ matrix.php_version }}
51+
curl http://localhost:8080/
52+
53+
# If on master branch, build and release images.
54+
release:
55+
name: Release
56+
runs-on: ubuntu-latest
57+
strategy:
58+
matrix:
59+
php_version:
60+
- '7.4'
61+
- '7.3'
62+
- '7.2'
63+
- '7.1'
64+
needs: test
65+
if: github.ref == 'refs/heads/master'
66+
67+
steps:
68+
- uses: actions/checkout@v2
69+
70+
- name: Set up Python 3.
71+
uses: actions/setup-python@v2
72+
with:
73+
python-version: '3.x'
74+
75+
- name: Install prerequisites.
76+
run: pip3 install ansible docker
77+
78+
- name: Install role dependencies.
79+
run: ansible-galaxy install -r requirements.yml
80+
81+
- name: Build the container.
82+
run: ansible-playbook --extra-vars="@vars/${{ matrix.php_version }}.yml" main.yml
83+
84+
- name: Login to DockerHub
85+
uses: docker/login-action@v1
86+
with:
87+
username: ${{ secrets.DOCKERHUB_USERNAME }}
88+
password: ${{ secrets.DOCKERHUB_TOKEN }}
89+
90+
- name: Push image.
91+
run: |
92+
# Push $solr_version tag.
93+
docker push geerlingguy/php-apache:${{ matrix.php_version }}
94+
95+
# Push $php_version + '.x' tag.
96+
docker tag geerlingguy/php-apache:${{ matrix.php_version }} geerlingguy/php-apache:${{ matrix.php_version }}.x
97+
docker push geerlingguy/php-apache:${{ matrix.php_version }}.x
98+
99+
# Push $php_version + '.PHP_RELEASE_VERSION' tag.
100+
php_release_version=$(docker run --rm geerlingguy/php-apache:${{ matrix.php_version }} bash -c "php -r 'echo PHP_RELEASE_VERSION;'")
101+
docker tag geerlingguy/php-apache:${{ matrix.php_version }} geerlingguy/php-apache:${{ matrix.php_version }}.${php_release_version}
102+
docker push geerlingguy/php-apache:${{ matrix.php_version }}.${php_release_version}
103+
104+
# Push latest tag if building latest version.
105+
if [[ "${{ matrix.php_version }}" == "7.4" ]]; then
106+
docker tag geerlingguy/php-apache:${{ matrix.php_version }} geerlingguy/php-apache:latest
107+
docker push geerlingguy/php-apache:latest
108+
fi

.travis.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PHP Apache Container (Built with Ansible)
22

3-
[![Build Status](https://travis-ci.org/geerlingguy/php-apache-container.svg?branch=master)](https://travis-ci.org/geerlingguy/php-apache-container) [![](https://images.microbadger.com/badges/image/geerlingguy/php-apache.svg)](https://microbadger.com/images/geerlingguy/php-apache "Get your own image badge on microbadger.com")
3+
[![CI](https://github.com/geerlingguy/php-apache-container/workflows/Build/badge.svg?branch=master&event=push)](https://github.com/geerlingguy/php-apache-container/actions?query=workflow%3ABuild) [![Docker pulls](https://img.shields.io/docker/pulls/geerlingguy/php-apache)](https://hub.docker.com/r/geerlingguy/php-apache/)
44

55
This project is composed of three main parts:
66

@@ -93,7 +93,7 @@ Then, make sure Docker is running, and run the playbook to build the container:
9393
9494
### Push the image to Docker Hub
9595

96-
See the `.travis.yml` file in this repository for how it pushes all the tagged images automatically on any commit to the `master` branch.
96+
See the `.github/workflows/build.yml` file in this repository for how it pushes all the tagged images automatically on any commit to the `master` branch.
9797

9898
## License
9999

docker-push

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)