Skip to content

CI

CI #76

Workflow file for this run

name: CI
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
schedule:
- cron: '0 0 * * 0'
jobs:
test_main:
name: Test MAIN
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 1
matrix:
target: [ base, debug ]
php: [ 7.4, 8.2 ]
wordpress: [ 6 ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
uses: docker/build-push-action@v3
with:
context: .
target: ${{ matrix.target }}
build-args: |
PHP_VERSION=${{ matrix.php }}
WP_VERSION=${{ matrix.wordpress }}
tags: php-fpm-nginx-wordpress:ci
load: true
- name: Start Container with Health Check
run: |
docker run -d --rm \
--name test \
-p 10000:80 \
--health-cmd "/usr/local/bin/healthcheck.sh" \
--health-interval=30s \
--health-timeout=30s \
--health-start-period=60s \
php-fpm-nginx-wordpress:ci
- name: Wait for container
timeout-minutes: 1
run: |
while status="$(docker inspect -f '{{ .State.Health.Status }}' test)"; do
case $status in
starting) sleep 1;;
healthy) exit 0;;
unhealthy) exit 1;;
esac
done
exit 1
- name: Test
run: curl http://localhost:10000
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
uses: docker/build-push-action@v3
with:
context: .
target: ${{ matrix.target }}
build-args: |
PHP_VERSION=${{ matrix.php }}
WP_VERSION=${{ matrix.wordpress }}
tags: marcortola/php-fpm-nginx-wordpress:${{ matrix.php }}${{ (matrix.target != 'base' && format('-{0}', matrix.target)) || '' }}
push: true