diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..beb01fa --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,48 @@ +name: Build and Deploy Docker Container + +on: + push: + branches: + [master, 'release/*'] + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: Build and push Docker image + run: | + docker build --build-arg NUGET_USERNAME=${{ secrets.NUGET_USERNAME }} --build-arg NUGET_PASSWORD=${{ secrets.NUGET_PASSWORD }} -t ${{ secrets.DOCKER_USERNAME }}/your-app-name:latest . + docker push ${{ secrets.DOCKER_USERNAME }}/your-app-name:latest + + - name: Start ssh-agent + id: ssh-agent + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Deploy to Server + env: + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_USER: ${{ secrets.SSH_USER }} + DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/mirea-bakend:latest + run: | + ssh-keyscan $SSH_HOST >> ~/.ssh/known_hosts + ssh $SSH_USER@$SSH_HOST " + docker pull $DOCKER_IMAGE && + docker stop mirea-bakend || true && + docker rm mirea-bakend || true && + docker run -d --name mirea-bakend -p 8085:8080 $DOCKER_IMAGE + " + + - name: Remove all keys from ssh-agent + run: ssh-add -D \ No newline at end of file diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 9d784b5..e870ad0 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout repository - uses: actions/checkout@v4 - name: Set up .NET Core diff --git a/Backend.sln b/Backend.sln index 81a8dbe..aa0141f 100644 --- a/Backend.sln +++ b/Backend.sln @@ -12,6 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution", .gitattributes = .gitattributes .gitignore = .gitignore Dockerfile = Dockerfile + .gitea\workflows\deploy.yaml = .gitea\workflows\deploy.yaml LICENSE.txt = LICENSE.txt README.md = README.md .gitea\workflows\test.yaml = .gitea\workflows\test.yaml diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..96674ab --- /dev/null +++ b/nuget.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file