diff --git a/.github/workflows/deploy-production.yaml b/.github/workflows/deploy-production.yaml new file mode 100644 index 0000000..2643126 --- /dev/null +++ b/.github/workflows/deploy-production.yaml @@ -0,0 +1,32 @@ +name: Deploy to production server + +concurrency: + group: production + cancel-in-progress: false + +on: + workflow_dispatch: + +jobs: + deploy: + name: Deploy to production server + runs-on: self-hosted + environment: + name: production + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_KEY }} + fingerprint: ${{ secrets.SSH_FINGERPRINT }} + script_stop: true # Stop script on error + script: | + cd ${{ secrets.REPOSITORY_ROOT }} + git reset --hard + git checkout ${{ github.ref_name }} + git pull + docker compose build + docker compose pull + docker compose up -d diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml new file mode 100644 index 0000000..e76c416 --- /dev/null +++ b/.github/workflows/deploy-staging.yaml @@ -0,0 +1,35 @@ +name: Deploy to staging server + +concurrency: + group: staging + cancel-in-progress: false + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + deploy: + name: Deploy to staging server + runs-on: self-hosted + environment: + name: staging + steps: + - name: Deploy via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_KEY }} + fingerprint: ${{ secrets.SSH_FINGERPRINT }} + script_stop: true # Stop script on error + script: | + cd ${{ secrets.REPOSITORY_ROOT }} + git reset --hard + git checkout ${{ github.ref_name }} + git pull + docker compose build + docker compose pull + docker compose up -d