Skip to content

🔀 Merge pull request #32 from likesistemas/feature/NFE-180_v2 #63

🔀 Merge pull request #32 from likesistemas/feature/NFE-180_v2

🔀 Merge pull request #32 from likesistemas/feature/NFE-180_v2 #63

name: PHP Dev
on:
push:
branches:
- master
tags:
- v*
pull_request:
jobs:
test:
strategy:
matrix:
PHP: [73, 74, 80, 81, 82, 83]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prepare code
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
touch .env
echo "IMAGE=sistema-core-dev" >> .env
echo "VERSAO=${PHP_VERSION}-dev" >> .env
echo "PASTA_WWW=www${PHP_VERSION}" >> .env
ln -s www80 www81
ln -s www80 www82
ln -s www80 www83
- name: Up environment
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
docker-compose \
--file docker-compose.yml \
--file docker-compose-${PHP_VERSION}.yml \
--file docker-compose.dev.yml \
up --build -d
- name: Wait environment
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
echo $(docker run -t --network lemp jwilder/dockerize \
-wait http://core_nginx/ \
-timeout 60s)
- name: Logs environment
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
docker ps -a
docker logs app
- name: Test -> Http Request
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
CONTENT=$(curl -s "http://127.0.0.1/");
echo "CHAMADA HTTP: ${CONTENT}";
if [ "${CONTENT}" != "core|${PHP_VERSION}" ]; then
echo "Chamada HTTP retornou errado: ${CONTENT}"
exit 1;
fi
- name: Test -> App Request
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
APP_CONTENT=$(docker exec app app echo);
echo "CHAMADA APP: ${APP_CONTENT}";
if [ "${APP_CONTENT}" != "core|${PHP_VERSION}" ]; then
echo "Chamada APP retornou errado: ${APP_CONTENT}"
exit 1;
fi
- name: Down environment
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
docker-compose \
--file docker-compose.yml \
--file docker-compose-${PHP_VERSION}.yml \
--file docker-compose.dev.yml \
down -v
- name: Production -> Up environment
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
docker-compose \
--file docker-compose.yml \
--file docker-compose-${PHP_VERSION}.yml \
--file docker-compose.dev.yml \
--file docker-compose.prod.yml \
up --build -d
- name: Production -> Wait environment
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
echo $(docker run -t --network lemp jwilder/dockerize \
-wait http://core_nginx/ \
-timeout 60s)
- name: Production -> Logs environment
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
docker ps -a
docker logs app
- name: Production -> Http test
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
CONTENT=$(curl -s "http://127.0.0.1/");
echo "CHAMADA HTTP: ${CONTENT}";
if [ "${CONTENT}" != "core|${PHP_VERSION}" ]; then
echo "Chamada HTTP retornou errado: ${CONTENT}"
exit 1;
fi
- name: Production -> App test
env:
PHP_VERSION: ${{ matrix.PHP }}
run: |
APP_CONTENT=$(docker exec app app echo);
echo "CHAMADA APP: ${APP_CONTENT}";
if [ "${APP_CONTENT}" != "core|${PHP_VERSION}" ]; then
echo "Chamada APP retornou errado: ${APP_CONTENT}"
exit 1;
fi
push:
needs: test
strategy:
matrix:
PHP: [73, 74, 80, 81, 82, 83]
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: Build and push
uses: docker/build-push-action@v2
with:
context: .
build-args: |
VERSAO_PHP=likesistemas/php-dev:${{ matrix.PHP }}
push: true
tags: |
likesistemas/sistema-core-dev:${{ matrix.PHP }}
# ghcr.io/likesistemas/sistema-core-dev:${{ matrix.PHP }}