From 8b47fef535cc8572321d12cf61eab53af7844976 Mon Sep 17 00:00:00 2001 From: Estebans441 Date: Mon, 18 Nov 2024 12:20:51 -0500 Subject: [PATCH] :rocket: add prod deploy script --- .github/workflows/deploy-prod.yml | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/deploy-prod.yml diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml new file mode 100644 index 0000000..b292e56 --- /dev/null +++ b/.github/workflows/deploy-prod.yml @@ -0,0 +1,33 @@ +name: Deploy PROD +on: + push: + tags: + - '*' + workflow_dispatch: +jobs: + Deploy: + name: Deploy on PROD + runs-on: self-hosted + steps: + - name: executing remote ssh commands using ssh key + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.PROD_G1_HOST }} + username: ${{ secrets.HOSTS_USERNAME }} + key: ${{ secrets.PROD_G1_SSH_KEY }} + port: ${{ secrets.SSH_PORT }} + script: | + cd AllConnected/${{ github.event.repository.name }} + echo "Fetching latest code..." + git fetch + git checkout main + git pull + echo "Building Docker image..." + docker build -t ${{ github.event.repository.name }} . + echo "Creating .env file..." + echo "PROFILE=prod1" >> .env + echo "CONFIG_IP=10.43.101.72" >> .env + docker rm -f ${{ github.event.repository.name }} + docker run --name ${{ github.event.repository.name }} --network all_connected -d -p ${{ secrets.SERVICE_PORT }}:8080 --env-file .env ${{ github.event.repository.name }} + echo "Docker container running..." + rm .env