From 8ab0ea023827079c6cdd16de20f584207c80dd7d Mon Sep 17 00:00:00 2001 From: Alex Zaharia Date: Tue, 9 Mar 2021 18:48:48 +0200 Subject: [PATCH] testing github workflow --- .github/.build-env | 2 +- .../workflows/run-containers-selfhosted.yml | 181 +++++++++--------- 2 files changed, 88 insertions(+), 95 deletions(-) diff --git a/.github/.build-env b/.github/.build-env index a5e67b68d3..6c716feb49 100644 --- a/.github/.build-env +++ b/.github/.build-env @@ -1,4 +1,4 @@ BUILD_ENVIRONMENT=master FREE_BRANCH=master PRO_BRANCH=master -EDITOR_BRANCH=master +EDITOR_BRANCH=dev diff --git a/.github/workflows/run-containers-selfhosted.yml b/.github/workflows/run-containers-selfhosted.yml index a05d65e051..ddab66e7cd 100644 --- a/.github/workflows/run-containers-selfhosted.yml +++ b/.github/workflows/run-containers-selfhosted.yml @@ -16,7 +16,7 @@ jobs: - name: Load Build Evnrorment Data uses: falti/dotenv-action@master - id: env + id: dotenv with: path: main/.github/.build-env @@ -24,7 +24,17 @@ jobs: id: vars shell: bash run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "::set-output name=MYSQL_CONTAINER_NAME::testing-mysql-${{ steps.dotenv.outputs.build_environment }}" + echo "::set-output name=EDITOR_CONTAINER_NAME::testing-editor-${{ steps.dotenv.outputs.build_environment }}" + echo "::set-output name=WORDPRESS_CONTAINER_NAME::testing-wordpress-${{ steps.dotenv.outputs.build_environment }}" + echo "::set-output name=COMPILER_CONTAINER_NAME::testing-compiler" + echo "::set-output name=WORDPRESS_IMAGE::brizy/testing-wordpress:${{ steps.dotenv.outputs.build_environment }}" + echo "::set-output name=EDITOR_IMAGE::brizy/testing-editor:${{ steps.dotenv.outputs.build_environment }}" + echo "::set-output name=MYSQL_IMAGE::brizy/testing-mysql:${{ steps.dotenv.outputs.build_environment }}" + echo "::set-output name=DB_NAME::brizy-${{ steps.dotenv.outputs.build_environment }}" + echo "::set-output name=BITBLOX_DOMAIN::${{ steps.dotenv.outputs.build_environment }}.editor.office.brizy.org" + echo "::set-output name=NETWORK::traefik" + echo "::set-output name=DOMAIN::${{ steps.dotenv.outputs.build_environment }}.wordpress.office.brizy.org" - name: Checkout BB uses: actions/checkout@v2 @@ -39,98 +49,81 @@ jobs: id: change-branches-on-bb shell: bash run: | - cd $GITHUB_WORKSPACE/bb/worpdress - cd $GITHUB_WORKSPACE/bb/editor && git fetch origin ${EDITOR_BRANCH} && git checkout ${EDITOR_BRANCH} - cd $GITHUB_WORKSPACE/bb/worpdress/www/wp-content/plugins/brizy && git fetch origin ${FREE_BRANCH} && git checkout ${FREE_BRANCH} - cd $GITHUB_WORKSPACE/bb/worpdress/www/wp-content/plugins/brizy-pro && git fetch origin ${PRO_BRANCH} && git checkout ${PRO_BRANCH} - -# - name: Build mysql image -# id: build-mysql-image -# shell: bash -# run: | -# mysqlContainerName="testing-mysql-${BUILD_ENVIRONMENT}" -# brizyMysqlImage="brizy/testing-mysql:${BUILD_ENVIRONMENT}" -# dbName="brizy-${target}" -# docker stop "${mysqlContainerName}" || true -# docker build -t "${brizyMysqlImage}" --target build-deployment bb/mysql -# docker run -d --rm --network="traefik" \ -# --network-alias="${mysqlContainerName}" \ -# --name="${mysqlContainerName}" \ -# --cpus=3 \ -# --memory=2g \ -# -e "MAX_CPUS=3" \ -# -e "MYSQL_ROOT_PASSWORD=nopassword" \ -# -e "MYSQL_DATABASE=${dbName}" \ -# -e "MYSQL_USER=brizy" \ -# -e "MYSQL_PASSWORD=nopassword" \ -# "${brizyMysqlImage}" - -# - name: Build wordpress image -# id: build-wordpress-image -# shell: bash -# run: | -# mysqlContainerName="testing-mysql-${BUILD_ENVIRONMENT}" -# brizyMysqlImage="brizy/testing-mysql:${BUILD_ENVIRONMENT}" -# dbName="brizy-${target}" -# docker stop "${mysqlContainerName}" || true -# docker build -t "${brizyMysqlImage}" --target build-deployment bb/mysql -# docker run -d --rm --network="${network}" \ -# --network-alias="${wpContainerName}" \ -# --name="${wpContainerName}" \ -# --cpus=2 \ -# --memory=2g \ -# -e "MAX_CPUS=2" \ -# -e "WORDPRESS_DB_HOST=${mysqlContainerName}" \ -# -e "WORDPRESS_DB_USER=root" \ -# -e "WORDPRESS_DB_PASSWORD=nopassword" \ -# -e "WORDPRESS_DB_NAME=${dbName}" \ -# -e "WORDPRESS_DEBUG=1" \ -# -e "APP_ENV=dev" \ -# -e "EDITOR_HOST=${editorContainerName}:3000" \ -# -e "COMPILER_HOST=${compilerContainerName}:5000" \ -# -e "STATIC_HOST=${bitbloxDomain}:8080" \ -# -e "COMPILER_DOWNLOAD_HOST=${wpContainerName}" \ -# -e "WORDPRESS_CONFIG_EXTRA= -# define('FS_METHOD', 'direct'); -# define( 'WP_HOME', 'http://${domainName}:8080/' ); -# define( 'WP_SITEURL', 'http://${domainName}:8080/' ); " \ -# --label "traefik.docker.network"="${network}" \ -# --label "traefik.enable"="true" \ -# --label "traefik.frontend.rule"="Host:${domainName}" \ -# --label "traefik.port"="80" \ -# "${brizyWordpressImage}" - - + cd $GITHUB_WORKSPACE/bb/editor && git fetch origin ${{ steps.dotenv.outputs.editor_branch }} && git checkout ${{ steps.dotenv.outputs.editor_branch }} + cd $GITHUB_WORKSPACE/bb/wordpress/www/wp-content/plugins/brizy && git fetch origin ${{ steps.dotenv.outputs.free_branch }} && git checkout ${{ steps.dotenv.outputs.free_branch }} + cd $GITHUB_WORKSPACE/bb/wordpress/www/wp-content/plugins/brizy-pro && git fetch origin ${{ steps.dotenv.outputs.pro_branch }} && git checkout ${{ steps.dotenv.outputs.pro_branch }} + - name: Build mysql image + id: build-mysql-image + shell: bash + run: | + docker stop "${{ steps.vars.outputs.MYSQL_CONTAINER_NAME }}" || true + docker build -t "${{ steps.vars.outputs.MYSQL_IMAGE }}" --target build-deployment $GITHUB_WORKSPACE/bb/mysql + docker run -d --rm --network="${{ steps.vars.outputs.NETWORK }}" \ + --network-alias="${{ steps.vars.outputs.MYSQL_CONTAINER_NAME }}" \ + --name="${{ steps.vars.outputs.MYSQL_CONTAINER_NAME }}" \ + --cpus=3 \ + --memory=2g \ + -e "MAX_CPUS=3" \ + -e "MYSQL_ROOT_PASSWORD=nopassword" \ + -e "MYSQL_DATABASE=${{ steps.vars.outputs.DB_NAME }}" \ + -e "MYSQL_USER=brizy" \ + -e "MYSQL_PASSWORD=nopassword" \ + "${{ steps.vars.outputs.MYSQL_IMAGE }}" + - name: Build wordpress image + id: build-wordpress-image + shell: bash + run: | + docker stop "${{ steps.vars.outputs.WORDPRESS_CONTAINER_NAME }}" || true + docker rmi "${{ steps.vars.outputs.WORDPRESS_IMAGE }}" || true + docker build -t "${{ steps.vars.outputs.WORDPRESS_IMAGE }}" \ + --build-arg COMPOSER_AUTH="{\"github-oauth\":{\"github.com\":\"${{ secrets.GITHUB_TOKEN }}\"}}" \ + --target wordpress $GITHUB_WORKSPACE/bb/wordpress + docker run -d --rm --network="${{ steps.vars.outputs.NETWORK }}" \ + --network-alias="${{ steps.vars.outputs.WORDPRESS_CONTAINER_NAME }}" \ + --name="${{ steps.vars.outputs.WORDPRESS_CONTAINER_NAME }}" \ + --cpus=2 \ + --memory=2g \ + -e "MAX_CPUS=2" \ + -e "WORDPRESS_DB_HOST=${{ steps.vars.outputs.MYSQL_CONTAINER_NAME }}" \ + -e "WORDPRESS_DB_USER=root" \ + -e "WORDPRESS_DB_PASSWORD=nopassword" \ + -e "WORDPRESS_DB_NAME=${{ steps.vars.outputs.DB_NAME }}" \ + -e "WORDPRESS_DEBUG=1" \ + -e "APP_ENV=dev" \ + -e "EDITOR_HOST=${{ steps.vars.outputs.EDITOR_CONTAINER_NAME }}:3000" \ + -e "COMPILER_HOST=${{ steps.vars.outputs.COMPILER_CONTAINER_NAME }}:5000" \ + -e "STATIC_HOST=${{ steps.vars.outputs.BITBLOX_DOMAIN }}:8080" \ + -e "COMPILER_DOWNLOAD_HOST=${{ steps.vars.outputs.WORDPRESS_CONTAINER_NAME }}" \ + -e "WORDPRESS_CONFIG_EXTRA= + define('FS_METHOD', 'direct'); + define( 'WP_HOME', 'http://${{ steps.vars.outputs.DOMAIN }}:8080/' ); + define( 'WP_SITEURL', 'http://${{ steps.vars.outputs.DOMAIN }}:8080/' ); " \ + --label "traefik.docker.network"="${{ steps.vars.outputs.NETWORK }}" \ + --label "traefik.enable"="true" \ + --label "traefik.frontend.rule"="Host:${{ steps.vars.outputs.DOMAIN }}" \ + --label "traefik.port"="80" \ + "${{ steps.vars.outputs.WORDPRESS_IMAGE }}" -# - name: Intialize the containers -# uses: appleboy/ssh-action@master -# with: -# host: ${{ secrets.HOST }} -# username: ${{ secrets.USERNAME }} -# key: ${{ secrets.KEY }} -# port: ${{ secrets.PORT }} -# command_timeout: 200m -# passphrase: ${{ secrets.KEY_PASSPHRASE }} -# script: | -# ./BB/build/run-editor-instance.sh \ -# -c ${{ steps.vars.outputs.sha_short }} \ -# -v ${{ steps.env.outputs.build_environment }} \ -# -f ${{ steps.env.outputs.free_branch }} \ -# -p ${{ steps.env.outputs.pro_branch }} \ -# -e ${{ steps.env.outputs.editor_branch }} \ -# -n traefik \ -# -t ${{ secrets.COMPOSER_TOKEN }} -# - name: Clean context folder -# uses: appleboy/ssh-action@master -# if: ${{ always() }} -# with: -# host: ${{ secrets.HOST }} -# username: ${{ secrets.USERNAME }} -# key: ${{ secrets.KEY }} -# port: ${{ secrets.PORT }} -# command_timeout: 200m -# passphrase: ${{ secrets.KEY_PASSPHRASE }} -# script: -# ./BB/build/clean-context-folder.sh -c ${{ steps.vars.outputs.sha_short }} + - name: Build Editor image + id: build-editor-image + shell: bash + run: | + docker stop "${{ steps.vars.outputs.EDITOR_CONTAINER_NAME }}" || true + docker rmi "${{ steps.vars.outputs.EDITOR_IMAGE }}" || true + docker build -t "${{ steps.vars.outputs.EDITOR_IMAGE }}" --target remote $GITHUB_WORKSPACE/bb/editor + docker run -d --rm --network="${{ steps.vars.outputs.NETWORK }}" \ + --network-alias="${{ steps.vars.outputs.EDITOR_CONTAINER_NAME }}" \ + --name="${{ steps.vars.outputs.EDITOR_CONTAINER_NAME }}" \ + --cpus=1 \ + --memory=1g \ + -e "MAX_CPUS=1" \ + --label "traefik.docker.network"="${{ steps.vars.outputs.NETWORK }}" \ + --label "traefik.enable"="true" \ + --label "traefik.frontend.rule"="Host:${{ steps.vars.outputs.BITBLOX_DOMAIN }}" \ + --label "traefik.port"="3000" \ + --label "traefik.frontend.headers.customRequestHeaders"="Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE,PUT" \ + --label "traefik.frontend.headers.customRequestHeaders"="Access-Control-Max-Age:1000" \ + --label "traefik.frontend.headers.customRequestHeaders"="Access-Control-Allow-Headers:x-requested-with,Content-Type,origin,authorization,accept,client-security-token" \ + "${{ steps.vars.outputs.EDITOR_IMAGE }}"