-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (79 loc) · 3.02 KB
/
Copy pathbuild.yml
File metadata and controls
98 lines (79 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Build and Push Docker Images
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
release:
types: [ published ]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pylint mypy black isort
pip install -r requirements.txt
# - name: Run flake8
# run: flake8 server client
# - name: Run pylint
# run: pylint server client
# - name: Run mypy
# run: mypy server client
# - name: Check formatting with black
# run: black --check server client
# - name: Check imports with isort
# run: isort --check-only --profile black server client
build:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp
- name: Build and push server image
uses: docker/build-push-action@v4
with:
context: .
file: ./server/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-server:${{ github.sha }},${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-server:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push client image
uses: docker/build-push-action@v4
with:
context: .
file: ./client/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-client:${{ github.sha }},${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-client:latest
cache-from: type=gha
cache-to: type=gha,mode=max
# Добавление тегов версии при релизе
- name: Tag release version
if: github.event_name == 'release'
run: |
VERSION=${GITHUB_REF#refs/tags/}
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-server:latest ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-server:${VERSION}
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-client:latest ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-client:${VERSION}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-server:${VERSION}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/lwmecps-testapp-client:${VERSION}