diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml deleted file mode 100644 index a2d1750..0000000 --- a/.github/workflows/deployment.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Deploying to VPS - -on: - push: - workflow_dispatch: - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Calculate short hash - run: | - shortHash=$(git rev-parse --short ${{ github.sha }}) - echo "COMMIT_SHORT_SHA=$shortHash" >> $GITHUB_ENV - - name: SSH setup and run commands - uses: appleboy/ssh-action@v1.0.3 - with: - host: ${{ secrets.SSH_HOST }} - key: ${{ secrets.SSH_KEY }} - username: ${{ secrets.SSH_USER }} - passphrase: ${{ secrets.SSH_PASSPHRASE }} - script: | - cd ./deploy/${{ github.event.repository.name }} - git pull - docker rm --force ${{ github.event.repository.name }}-deploy 2> /dev/null - docker build -t ${{ github.repository }}:${{ env.COMMIT_SHORT_SHA }} --quiet . - docker run --detach --publish 5000:5000 --name ${{ github.event.repository.name }}-deploy ${{ github.repository }}:${{ env.COMMIT_SHORT_SHA }} - docker container prune --force && docker image prune --all --force diff --git a/.github/workflows/docker-deploy.yml b/.github/workflows/docker-deploy.yml new file mode 100644 index 0000000..450ce41 --- /dev/null +++ b/.github/workflows/docker-deploy.yml @@ -0,0 +1,33 @@ +name: Deploying to VPS + +on: + push: + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Deploy 🚀 + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.SSH_HOST }} + key: ${{ secrets.SSH_KEY }} + username: ${{ secrets.SSH_USER }} + passphrase: ${{ secrets.SSH_PASSPHRASE }} + script: | + cd ./deploy-main/${{ github.event.repository.name }} + git pull + docker container rm -f cyscom-opensrc || true + docker image rm -f cyscom-opensrc || true + docker build -t cyscom-opensrc --quiet . + docker run -d \ + --name cyscom-opensrc \ + -p 5000:5000 \ + --restart=always \ + --env-file ./../.env.web \ + cyscom-opensrc