diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b31dcfa..0cde71f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -3,25 +3,48 @@ name: Build and Deploy on: push: branches: - - staging # Triggers workflow on push to the main branch + - main + - staging jobs: - deploy_instance_1: - if: github.ref == 'refs/heads/staging' - runs-on: ubuntu-latest + deploy_instance_1: + if: github.ref == 'refs/heads/staging' + runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 + steps: + - name: Checkout code + uses: actions/checkout@v3 - - name: Deploy to Instance 1 - uses: appleboy/ssh-action@v0.1.8 - with: - host: ${{ secrets.INSTANCE_1_SERVER_HOST }} - username: ${{ secrets.INSTANCE_1_SERVER_USER }} - key: ${{ secrets.INSTANCE_1_SERVER_KEY }} - script: | - cd /root/shutter-explorer - git pull origin staging - cd docker - docker compose up -d --build \ No newline at end of file + - name: Deploy to Instance 1 + uses: appleboy/ssh-action@v0.1.8 + with: + host: ${{ secrets.STAGING_SERVER_HOST }} + username: ${{ secrets.STAGING_SERVER_USER }} + key: ${{ secrets.SERVER_KEY }} + script: | + cd /root/shutter-explorer + git pull origin staging + git submodule --init --recursive + cd docker + docker compose up -d --build + + deploy_instance_2: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Deploy to Instance 2 + uses: appleboy/ssh-action@v0.1.8 + with: + host: ${{ secrets.PROD_SERVER_HOST }} + username: ${{ secrets.PROD_SERVER_USER }} + key: ${{ secrets.SERVER_KEY }} + script: | + cd /root/shutter-explorer + git pull origin main + git submodule --init --recursive + cd docker + docker compose up -d --build \ No newline at end of file