From c9a85d029922da0c81f6908fc366328c3e1be9f4 Mon Sep 17 00:00:00 2001 From: Fabiano Mallmann <25328512+fabiano-mallmann@users.noreply.github.com> Date: Mon, 14 Aug 2023 16:51:18 -0300 Subject: [PATCH] cd: add new images to cd (#215) --- .github/data/docker-compose.yml | 2 +- .github/data/master/Dockerfile | 6 +++ .github/data/php8/Dockerfile | 6 +++ .github/data/{ => stg}/Dockerfile | 2 +- .github/data/test/Dockerfile | 6 +++ .github/workflows/cd_master.yml | 17 +++++++ .github/workflows/{cd.yml => cd_reusable.yml} | 44 +++++++++---------- .github/workflows/cd_stg.yml | 17 +++++++ .github/workflows/cd_test.yml | 17 +++++++ 9 files changed, 92 insertions(+), 25 deletions(-) create mode 100644 .github/data/master/Dockerfile create mode 100644 .github/data/php8/Dockerfile rename .github/data/{ => stg}/Dockerfile (66%) create mode 100644 .github/data/test/Dockerfile create mode 100644 .github/workflows/cd_master.yml rename .github/workflows/{cd.yml => cd_reusable.yml} (55%) create mode 100644 .github/workflows/cd_stg.yml create mode 100644 .github/workflows/cd_test.yml diff --git a/.github/data/docker-compose.yml b/.github/data/docker-compose.yml index 7684270e..e4470411 100644 --- a/.github/data/docker-compose.yml +++ b/.github/data/docker-compose.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3.4' volumes: mariadb_data: driver: local diff --git a/.github/data/master/Dockerfile b/.github/data/master/Dockerfile new file mode 100644 index 00000000..37b9bb56 --- /dev/null +++ b/.github/data/master/Dockerfile @@ -0,0 +1,6 @@ +FROM bitnami/magento:2.4.5 +MAINTAINER Open Source Team + +WORKDIR /opt/bitnami/magento +COPY auth.json /opt/bitnami/magento +RUN composer require pagarme/pagarme-magento2-module:master \ No newline at end of file diff --git a/.github/data/php8/Dockerfile b/.github/data/php8/Dockerfile new file mode 100644 index 00000000..c6c01979 --- /dev/null +++ b/.github/data/php8/Dockerfile @@ -0,0 +1,6 @@ +FROM bitnami/magento:2.4.5 +MAINTAINER Open Source Team + +WORKDIR /opt/bitnami/magento +COPY auth.json /opt/bitnami/magento +RUN composer require pagarme/pagarme-magento2-module:dev-stg \ No newline at end of file diff --git a/.github/data/Dockerfile b/.github/data/stg/Dockerfile similarity index 66% rename from .github/data/Dockerfile rename to .github/data/stg/Dockerfile index 73c89f8a..29337b5d 100644 --- a/.github/data/Dockerfile +++ b/.github/data/stg/Dockerfile @@ -3,4 +3,4 @@ MAINTAINER Open Source Team WORKDIR /opt/bitnami/magento COPY auth.json /opt/bitnami/magento -RUN composer require pagarme/pagarme-magento2-module +RUN composer require pagarme/pagarme-magento2-module:dev-stg \ No newline at end of file diff --git a/.github/data/test/Dockerfile b/.github/data/test/Dockerfile new file mode 100644 index 00000000..0d26b853 --- /dev/null +++ b/.github/data/test/Dockerfile @@ -0,0 +1,6 @@ +FROM bitnami/magento:2.4.3 +MAINTAINER Open Source Team + +WORKDIR /opt/bitnami/magento +COPY auth.json /opt/bitnami/magento +RUN composer require pagarme/pagarme-magento2-module:dev-test \ No newline at end of file diff --git a/.github/workflows/cd_master.yml b/.github/workflows/cd_master.yml new file mode 100644 index 00000000..b2a7ccef --- /dev/null +++ b/.github/workflows/cd_master.yml @@ -0,0 +1,17 @@ +name: CD Master + +on: + pull_request: + branches: ["master"] + types: closed +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + call-workflow-cd: + uses: pagarme/magento2/.github/workflows/cd_reusable.yml@master + with: + matrix_tags: "['master']" + secrets: + inherit \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd_reusable.yml similarity index 55% rename from .github/workflows/cd.yml rename to .github/workflows/cd_reusable.yml index 31a80f23..528cf735 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd_reusable.yml @@ -1,19 +1,17 @@ -name: CD +name: CD REUSABLE on: - push: - branches: - - develop - - test - - stg - - master -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + workflow_call: + inputs: + matrix_tags: + required: true + type: string jobs: - publish: + strategy: + matrix: + tags: ${{ fromJson( inputs.matrix_tags ) }} name: Publish runs-on: ubuntu-latest steps: @@ -25,7 +23,7 @@ jobs: run: | cp .github/data/auth.json . cp .github/data/docker-compose.yml . - cp .github/data/Dockerfile . + cp .github/data/${{ matrix.tags }}/Dockerfile . cp .github/data/wait-for-mysql.sh . cp .github/data/magento2_module_install.sql . - @@ -55,15 +53,15 @@ jobs: with: context: . push: true - tags: ${{ steps.meta.outputs.tags }} + tags: mpdockerregistry.azurecr.io/magento2-pagarme:${{ matrix.tags }} labels: ${{ steps.meta.outputs.labels }} - # name: Commit and push Docker image - # run: | - # sleep 5 && docker stop magento2_bitnami - # docker login ${{ secrets.DOCKER_ACCOUNT }} -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - # docker commit magento2_bitnami "magento2-pagarme:${{ github.ref_name }}" - # docker push "magento2-pagarme:${{ github.ref_name }}" - # name: Send deployment webhook to Rancher - # run: | - # BODY='{"push_data":{"tag":"'"${{ github.ref }}"'"},"repository":{"repo_name":"'"${{ secrets.DOCKER_ACCOUNT }}/${{ github.repository }}"'"}}' - # curl -X POST ${{ secrets.RANCHER_STG_DEPLOY_URL }} -H 'Content-Type: application/json' -d "${BODY}" + # name: Commit and push Docker image + # run: | + # sleep 5 && docker stop magento2_bitnami + # docker login ${{ secrets.DOCKER_ACCOUNT }} -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + # docker commit magento2_bitnami "magento2-pagarme:${{ github.ref_name }}" + # docker push "magento2-pagarme:${{ github.ref_name }}" + # name: Send deployment webhook to Rancher + # run: | + # BODY='{"push_data":{"tag":"'"${{ github.ref }}"'"},"repository":{"repo_name":"'"${{ secrets.DOCKER_ACCOUNT }}/${{ github.repository }}"'"}}' + # curl -X POST ${{ secrets.RANCHER_STG_DEPLOY_URL }} -H 'Content-Type: application/json' -d "${BODY}" \ No newline at end of file diff --git a/.github/workflows/cd_stg.yml b/.github/workflows/cd_stg.yml new file mode 100644 index 00000000..b864f301 --- /dev/null +++ b/.github/workflows/cd_stg.yml @@ -0,0 +1,17 @@ +name: CD STG AND PHP8 + +on: + pull_request: + branches: ["stg"] + types: closed +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + call-workflow-cd: + uses: pagarme/magento2/.github/workflows/cd_reusable.yml@master + with: + matrix_tags: "['stg', 'php8']" + secrets: + inherit \ No newline at end of file diff --git a/.github/workflows/cd_test.yml b/.github/workflows/cd_test.yml new file mode 100644 index 00000000..9049874d --- /dev/null +++ b/.github/workflows/cd_test.yml @@ -0,0 +1,17 @@ +name: CD TEST + +on: + pull_request: + branches: ["develop"] + types: closed +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + call-workflow-cd: + uses: pagarme/magento2/.github/workflows/cd_reusable.yml@master + with: + matrix_tags: "['test']" + secrets: + inherit \ No newline at end of file