build: try create image
Some checks failed
.NET Test Pipeline / build-and-test (push) Successful in 4m26s
Build and Deploy Docker Container / build-and-deploy (push) Failing after 3m24s

This commit is contained in:
Polianin Nikita 2024-07-02 23:42:29 +03:00
parent 2e2cee2ca7
commit de2f909ed6
3 changed files with 19 additions and 13 deletions

View File

@ -6,7 +6,7 @@ on:
[master, 'release/*']
jobs:
build_and_deploy:
build-and-deploy:
runs-on: ubuntu-latest
steps:
@ -16,13 +16,19 @@ jobs:
- 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: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Create nuget.config from secret
run: echo "${{ secrets.NUGET_CONFIG }}" > nuget.config
- 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 }}/mirea-bakend:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/mirea-bakend:latest
docker build --build-arg NUGET_USERNAME=${{ secrets.NUGET_USERNAME }} --build-arg NUGET_PASSWORD=${{ secrets.NUGET_PASSWORD }} -t ${{ secrets.DOCKER_USERNAME }}/mirea-backend:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/mirea-backend:latest
- name: Start ssh-agent
id: ssh-agent
@ -34,15 +40,15 @@ jobs:
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/mirea-bakend:latest
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/mirea-backend: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
docker stop mirea-backend || true &&
docker rm mirea-backend || true &&
docker run -d --name mirea-backend -p 8085:8080 $DOCKER_IMAGE
"
- name: Remove all keys from ssh-agent
run: ssh-add -D
run: ssh-add -D

View File

@ -12,12 +12,12 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@v4
uses: actions/checkout@v4
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore

View File

@ -11,8 +11,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Elements of the solution",
.env = .env
.gitattributes = .gitattributes
.gitignore = .gitignore
.gitea\workflows\deploy-stage.yaml = .gitea\workflows\deploy-stage.yaml
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