From 34344b990d43699a72d12e8dea7857ef2d22add0 Mon Sep 17 00:00:00 2001 From: Pierre Gauthier Date: Tue, 21 Nov 2023 17:56:25 +0100 Subject: [PATCH] Create github workflow to deploy --- .github/workflows/deploy-demo.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/deploy-demo.yml diff --git a/.github/workflows/deploy-demo.yml b/.github/workflows/deploy-demo.yml new file mode 100644 index 0000000..c9802c2 --- /dev/null +++ b/.github/workflows/deploy-demo.yml @@ -0,0 +1,30 @@ +name: Deploy demo + +on: + workflow_dispatch: + +jobs: + deploy-demo: + name: Deploy demo + if: | + always() && + (needs.tests.result == 'success' || needs.tests.result == 'skipped') + steps: + - name: Deploy in EC2 + env: + BRANCH: ${{ format('origin/{0}', github.ref_name) }} + PRIVATE_KEY: ${{ secrets.AWS_DEPLOY_KEY }} + HOSTNAME : ${{ secrets.AWS_HOSTNAME }} + USER_NAME : ${{ secrets.AWS_USER }} + run: | + echo "$PRIVATE_KEY" > private_key && chmod 600 private_key + ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} " + cd /home/ubuntu/ && + [ -d gally ] || git clone https://github.com/Elastic-Suite/sylius-demo.git gally && + cd /home/ubuntu/sylius && + docker system prune -af && + ([[ $(docker volume ls -q | awk '!/_/' | tr '\n' ' ' | wc -l) -eq 0 ]] || docker volume rm $(docker volume ls -q | awk '!/_/' | tr '\n' ' ')) && + docker compose down && + git fetch --all && git reset --hard && git checkout ${{ env.BRANCH }} && + docker compose -f docker-compose.yml -f docker-compose.int.yml up -d --build + "