diff --git a/deploy-asp-net-core.yml b/deploy-asp-net-core.yml new file mode 100644 index 0000000..80129ca --- /dev/null +++ b/deploy-asp-net-core.yml @@ -0,0 +1,50 @@ +name: Reusable Deploy + +on: + workflow_call: + inputs: + image_ref: + required: true + type: string + + container_name: + required: true + type: string + + port: + required: true + type: string + + secrets: + SSH_HOST: + required: true + + SSH_USER: + required: true + + SSH_PRIVATE_KEY: + required: true + +jobs: + deploy: + runs-on: docker-build + + steps: + - name: Deploy + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + + script: | + docker pull ${{ inputs.image_ref }} + + docker stop ${{ inputs.container_name }} || true + docker rm ${{ inputs.container_name }} || true + + docker run -d \ + --name ${{ inputs.container_name }} \ + --restart unless-stopped \ + -p ${{ inputs.port }} \ + ${{ inputs.image_ref }} \ No newline at end of file