From 7ccf7f3d202a0457fe56d01716681e7a93002be9 Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Tue, 6 Feb 2024 09:38:14 -0600 Subject: [PATCH 1/2] ASI-4532 Add Magento github workflow to deploy to dev environment --- .github/workflows/deploy_to_dev.yml | 57 +++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/deploy_to_dev.yml diff --git a/.github/workflows/deploy_to_dev.yml b/.github/workflows/deploy_to_dev.yml new file mode 100644 index 0000000..41383f0 --- /dev/null +++ b/.github/workflows/deploy_to_dev.yml @@ -0,0 +1,57 @@ +name: Deploy Magento2 Plugin to ADS Dev environment # http://ec2-100-25-3-18.compute-1.amazonaws.com + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Clear target directory on EC2 + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: 22 + script: | + rm -rf /home/ubuntu/github-workflow/* + + - name: Copy plugin to EC2 + uses: appleboy/scp-action@master + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: 22 + source: "." + target: "/home/ubuntu/github-workflow" # temp location on ec2 + + - name: SSH commands + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: 22 + script: | + cd /var/www/magento2 + + # Uninstall old plugin + php bin/magento module:disable Bread_BreadCheckout --clear-static-content + rm -rf app/code/Bread/Bread_BreadCheckout/* + + # Copy new plugin files + cp -R /home/ubuntu/github-workflow app/code/Bread/Bread_BreadCheckout + + # Install new plugin + php bin/magento module:enable Bread_BreadCheckout --clear-static-content + php bin/magento setup:upgrade + php -dmemory_limit=2G bin/magento setup:di:compile + php bin/magento cache:flush From 642a75c6c6d5ad6f9e723c1ba29f5f730f69d902 Mon Sep 17 00:00:00 2001 From: Farhan Khan Date: Wed, 7 Feb 2024 15:55:42 -0600 Subject: [PATCH 2/2] ASI-4532 Update env keys --- .github/workflows/deploy_to_dev.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy_to_dev.yml b/.github/workflows/deploy_to_dev.yml index 41383f0..b987974 100644 --- a/.github/workflows/deploy_to_dev.yml +++ b/.github/workflows/deploy_to_dev.yml @@ -16,8 +16,8 @@ jobs: - name: Clear target directory on EC2 uses: appleboy/ssh-action@master with: - host: ${{ secrets.EC2_HOST }} - username: ${{ secrets.EC2_USER }} + host: ${{ env.ADS_HOST }} + username: ${{ env.ADS_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 script: | @@ -26,8 +26,8 @@ jobs: - name: Copy plugin to EC2 uses: appleboy/scp-action@master with: - host: ${{ secrets.EC2_HOST }} - username: ${{ secrets.EC2_USER }} + host: ${{ env.ADS_HOST }} + username: ${{ env.ADS_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 source: "." @@ -36,8 +36,8 @@ jobs: - name: SSH commands uses: appleboy/ssh-action@master with: - host: ${{ secrets.EC2_HOST }} - username: ${{ secrets.EC2_USER }} + host: ${{ env.ADS_HOST }} + username: ${{ env.ADS_USER }} key: ${{ secrets.SSH_PRIVATE_KEY }} port: 22 script: |