diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..1035935 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,37 @@ +name: Deploy Docker Container + +on: + workflow_run: + workflows: ["Build and Push Docker Image"] + types: + - completed + branches: + - main + - dev + +jobs: + deploy: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_branch }} + + - name: Deploy to Docker + run: | + mkdir -p ~/.ssh + echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts + + BRANCH="${{ github.event.workflow_run.head_branch }}" + DEPLOY_PATH="${{ secrets.DEPLOY_PATH }}" + + ssh -i ~/.ssh/deploy_key ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << EOF + cd ${DEPLOY_PATH} + docker-compose pull lcc-app-${BRANCH} + docker-compose --profile ${BRANCH} up -d lcc-app-${BRANCH} + EOF \ No newline at end of file