Merge pull request #30 from likesistemas/feature/disable-config #71
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHP | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- v* | |
pull_request: | |
jobs: | |
test: | |
strategy: | |
matrix: | |
PHP: [56, 73, 74, 80, 81] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Prepare code | |
env: | |
PHP_VERSION: ${{ matrix.PHP }} | |
run: | | |
touch .env | |
echo "PHP_VERSION=${PHP_VERSION}" | |
echo "VERSAO=${PHP_VERSION}-dev" >> .env | |
echo "PASTA_WWW=www${PHP_VERSION}" >> .env | |
- name: Run tests dev | |
env: | |
PHP_VERSION: ${{ matrix.PHP }} | |
run: | | |
docker-compose -f docker-compose.yml \ | |
-f docker-compose-${PHP_VERSION}.yml \ | |
up --build -d | |
echo $(docker run -t --network lemp jwilder/dockerize \ | |
-wait http://core_nginx/ \ | |
-timeout 60s) | |
docker ps -a | |
docker logs app | |
CONTENT=$(curl -s "http://127.0.0.1/"); | |
APP_CONTENT=$(docker exec app app echo); | |
echo "CHAMADA HTTP: ${CONTENT}"; | |
echo "CHAMADA APP: ${APP_CONTENT}"; | |
if [ "${CONTENT}" != "core|${PHP_VERSION}" ]; then | |
echo "Chamada HTTP retornou errado: ${CONTENT}" | |
exit 1; | |
fi | |
if [ "${APP_CONTENT}" != "core|${PHP_VERSION}" ]; then | |
echo "Chamada APP retornou errado: ${APP_CONTENT}" | |
exit 1; | |
fi | |
docker-compose -f docker-compose.yml \ | |
-f docker-compose-${PHP_VERSION}.yml \ | |
down -v | |
- name: Run tests app | |
env: | |
PHP_VERSION: ${{ matrix.PHP }} | |
run: | | |
APP_RUN=$( | |
docker-compose -f docker-compose.yml \ | |
-f docker-compose-${PHP_VERSION}.yml \ | |
run -w /var/www/ --entrypoint entrypoint-app app echo | |
) | |
echo "CHAMADA APP: ${APP_RUN}"; | |
if [[ ! "${APP_RUN}" =~ "core|${PHP_VERSION}" ]]; then | |
echo "Chamada APP retornou errado: ${APP_RUN}" | |
exit 1; | |
fi | |
- name: Run tests config disabled | |
if: matrix.PHP == '80' | |
env: | |
PHP_VERSION: ${{ matrix.PHP }} | |
run: | | |
docker-compose -f docker-compose.yml \ | |
-f docker-compose-${PHP_VERSION}.yml \ | |
-f docker-compose-config-disabled.yml \ | |
up --build -d | |
echo $(docker run -t --network lemp jwilder/dockerize \ | |
-wait http://core_nginx/ \ | |
-timeout 60s) | |
docker ps -a | |
docker logs app | |
CONTENT=$(curl -s "http://127.0.0.1/"); | |
echo "CHAMADA HTTP: ${CONTENT}"; | |
if [ "${CONTENT}" != "core|${PHP_VERSION}|empty" ]; then | |
echo "Chamada HTTP retornou errado: ${CONTENT}" | |
exit 1; | |
fi | |
docker-compose -f docker-compose.yml \ | |
-f docker-compose-${PHP_VERSION}.yml \ | |
-f docker-compose-config-disabled.yml \ | |
down -v | |
- name: Run tests prod | |
env: | |
PHP_VERSION: ${{ matrix.PHP }} | |
run: | | |
docker-compose -f docker-compose.yml \ | |
-f docker-compose-${PHP_VERSION}.yml \ | |
-f docker-compose.prod.yml \ | |
up --build -d | |
echo $(docker run -t --network lemp jwilder/dockerize \ | |
-wait http://core_nginx/ \ | |
-timeout 60s) | |
docker ps -a | |
docker logs app | |
CONTENT=$(curl -s "http://127.0.0.1/"); | |
APP_CONTENT=$(docker exec app app echo); | |
echo "CHAMADA HTTP: ${CONTENT}"; | |
echo "CHAMADA APP: ${APP_CONTENT}"; | |
if [ "${CONTENT}" != "core|${PHP_VERSION}" ]; then | |
echo "Chamada HTTP retornou errado: ${CONTENT}" | |
exit 1; | |
fi | |
if [ "${APP_CONTENT}" != "core|${PHP_VERSION}" ]; then | |
echo "Chamada APP retornou errado: ${APP_CONTENT}" | |
exit 1; | |
fi | |
push: | |
needs: test | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: PHP 5.6 -> Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
build-args: | | |
VERSAO_PHP=likesistemas/php:56 | |
push: true | |
tags: | | |
likesistemas/sistema-core:56 | |
likesistemas/sistema-core:5.6 | |
ghcr.io/likesistemas/sistema-core:56 | |
ghcr.io/likesistemas/sistema-core:5.6 | |
- name: PHP 7.3 -> Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
build-args: | | |
VERSAO_PHP=likesistemas/php:73 | |
push: true | |
tags: | | |
likesistemas/sistema-core:latest | |
likesistemas/sistema-core:73 | |
likesistemas/sistema-core:7.3 | |
ghcr.io/likesistemas/sistema-core:latest | |
ghcr.io/likesistemas/sistema-core:73 | |
ghcr.io/likesistemas/sistema-core:7.3 | |
- name: PHP 7.4 -> Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
build-args: | | |
VERSAO_PHP=likesistemas/php:74 | |
push: true | |
tags: | | |
likesistemas/sistema-core:74 | |
likesistemas/sistema-core:7.4 | |
ghcr.io/likesistemas/sistema-core:74 | |
ghcr.io/likesistemas/sistema-core:7.4 | |
- name: PHP 8.0 -> Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
build-args: | | |
VERSAO_PHP=likesistemas/php:80 | |
push: true | |
tags: | | |
likesistemas/sistema-core:80 | |
likesistemas/sistema-core:8.0 | |
ghcr.io/likesistemas/sistema-core:80 | |
ghcr.io/likesistemas/sistema-core:8.0 | |
- name: PHP 8.1 -> Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
build-args: | | |
VERSAO_PHP=likesistemas/php:81 | |
push: true | |
tags: | | |
likesistemas/sistema-core:81 | |
likesistemas/sistema-core:8.1 | |
ghcr.io/likesistemas/sistema-core:81 | |
ghcr.io/likesistemas/sistema-core:8.1 |