diff --git a/.github/workflows/actions/archive-shop/action.yml b/.github/workflows/actions/archive-shop/action.yml new file mode 100644 index 00000000..b7016880 --- /dev/null +++ b/.github/workflows/actions/archive-shop/action.yml @@ -0,0 +1,47 @@ +name: Archive shop +description: Archive shop to share with future jobs, the action exports sources sql and xml checksum (optional) +inputs: + ps_dir: + description: Directory target + required: true + db_user: + description: DB user + required: true + db_password: + description: DB password + required: true + db_name: + description: DB name + required: true + artifact_name: + description: Artifact name, used later for download + required: false + default: shop-artifacts + +runs: + using: "composite" + steps: + - name: Archive shop content + run: | + mkdir -p /tmp/${{ inputs.artifact_name }} + pushd ${{ inputs.ps_dir }}; zip -q -r /tmp/${{ inputs.artifact_name }}/sources.zip * -x \ + "*/admin-dev/themes/new-theme/node_modules/**/*" \ + "*/admin-dev/themes/default/node_modules/**/*" \ + "*/themes/classic/_dev/**/*" \ + "*/themes/_core/**/*" \ + "*/themes/node_modules/**/*" \ + "*/install-dev/**/*" \ + "*/translations/*.zip" \ + "*/var/cache/**/*" \ + "*/tests/Integration/**/*" \ + "*/tests/Resources/**/*" \ + "*/tests/Unit/**/*" \ + "*/.git/**/*"; popd + docker exec my_prestashop_mysql_1 /usr/bin/mysqldump -u ${{ inputs.db_user }} -p${{ inputs.db_password }} ${{ inputs.db_name }} > /tmp/${{ inputs.artifact_name }}/db_dump.sql + shell: bash + + - name: Upload shop artifacts "${{ inputs.artifact_name }}" + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.artifact_name }} + path: /tmp/${{ inputs.artifact_name }} diff --git a/.github/workflows/actions/archive-shop/download/action.yml b/.github/workflows/actions/archive-shop/download/action.yml new file mode 100644 index 00000000..8fd71d86 --- /dev/null +++ b/.github/workflows/actions/archive-shop/download/action.yml @@ -0,0 +1,31 @@ +name: Download archive shop +description: Download archive shop and extracts it to the specified folder +inputs: + target_folder: + description: Target folder for extraction + required: true + artifact_name: + description: Artifact name, used later for download + required: false + default: shop-artifacts +outputs: + source-path: + description: Path to the sources zip file + value: /tmp/${{ inputs.artifact_name }}/sources.zip + db-dump-path: + description: Path to the sources zip file + value: /tmp/${{ inputs.artifact_name }}/db_dump.sql + +runs: + using: "composite" + steps: + - name: Download docker artifacts + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.artifact_name }} + path: /tmp/${{ inputs.artifact_name }} + + - name: Extract PrestaShop sources + run: | + unzip /tmp/${{ inputs.artifact_name }}/sources.zip -d ${{ inputs.target_folder }} + shell: bash diff --git a/.github/workflows/sub-workflows/build-shop.yml b/.github/workflows/sub-workflows/build-shop.yml index 83c4ddba..63c8e202 100644 --- a/.github/workflows/sub-workflows/build-shop.yml +++ b/.github/workflows/sub-workflows/build-shop.yml @@ -198,29 +198,12 @@ jobs: # Prepare archive contents to share with following jobs - name: Archive shop content if: always() - run: | - mkdir -p /tmp/shop-artifacts - zip -q -r /tmp/shop-artifacts/sources.zip ${{ env.PS_DIR }} -x \ - "*/admin-dev/themes/new-theme/node_modules/**/*" \ - "*/admin-dev/themes/default/node_modules/**/*" \ - "*/themes/classic/_dev/**/*" \ - "*/themes/_core/**/*" \ - "*/themes/node_modules/**/*" \ - "*/install-dev/**/*" \ - "*/translations/*.zip" \ - "*/var/cache/**/*" \ - "*/tests/Integration/**/*" \ - "*/tests/Resources/**/*" \ - "*/tests/Unit/**/*" \ - "*/.git/**/*" - docker exec my_prestashop_mysql_1 /usr/bin/mysqldump -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} ${{ env.DB_NAME }} > /tmp/shop-artifacts/db_dump.sql - - - name: Upload shop artifacts - if: always() - uses: actions/upload-artifact@v3 + uses: ./custom_actions/.github/workflows/actions/archive-shop with: - name: shop-artifacts - path: /tmp/shop-artifacts + ps_dir: ${{ env.PS_DIR }} + db_user: ${{ env.DB_USER }} + db_password: ${{ env.DB_PASSWD }} + db_name: ${{ env.DB_NAME }} - name: Save logs in case of error uses: actions/upload-artifact@v3 diff --git a/.github/workflows/sub-workflows/test-with-prebuilt-shop.yml b/.github/workflows/sub-workflows/test-with-prebuilt-shop.yml index 7465a3f5..5dd7c092 100644 --- a/.github/workflows/sub-workflows/test-with-prebuilt-shop.yml +++ b/.github/workflows/sub-workflows/test-with-prebuilt-shop.yml @@ -66,14 +66,10 @@ jobs: path: custom_actions - name: Download docker artifacts - uses: actions/download-artifact@v3 + id: download-shop + uses: ./custom_actions/.github/workflows/actions/archive-shop/download with: - name: shop-artifacts - path: /tmp/shop-artifacts - - - name: Extract PrestaShop sources - run: | - unzip /tmp/shop-artifacts/sources.zip -d . + target_folder: ${{ env.PS_DIR }} # Pre pull/build images - name: Pull mysql in background @@ -121,7 +117,7 @@ jobs: sleep 10 until docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }}; do echo "Sleep and retry to check"; sleep 2; done echo Copying dump into docker - docker cp /tmp/shop-artifacts/db_dump.sql my_prestashop_mysql_1:/tmp/db_dump.sql + docker cp ${{ steps.download-shop.outputs.db-dump-path }} my_prestashop_mysql_1:/tmp/db_dump.sql echo Creating ${{ env.DB_NAME }} database docker exec my_prestashop_mysql_1 /usr/bin/mysql -u ${{ env.DB_USER }} -p${{ env.DB_PASSWD }} -e "CREATE DATABASE IF NOT EXISTS ${{ env.DB_NAME }};" echo Load dump into DB