diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..94b3845 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build and backup docker conteiner + +on: + # Сработает при создании pull request в master ветку + pull_request: + branches: + - master + +jobs: + # Сборка контейнера + build: + name: Run build conteiner + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: | + make docker-build + env: + PORT_APP: ${{ secrets.PORT_APP }} + # Отправка образа в dockerhub + push_dockerhub: + name: Push image to docker hub + runs-on: ubuntu-latest + needs: build # ждёт успешной сборки + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/web-robot-control-app:latest + build-args: | + PORT_APP=${{ secrets.PORT_APP }}