devops: added jobs for build conteiner and push image to docker hub
This commit is contained in:
53
.github/workflows/build.yml
vendored
Normal file
53
.github/workflows/build.yml
vendored
Normal file
@@ -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 }}
|
||||||
Reference in New Issue
Block a user