-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (51 loc) · 1.65 KB
/
Copy pathPython-Package.yml
File metadata and controls
54 lines (51 loc) · 1.65 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
name: Python Package
on: [push]
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Install pytest
run: |
pip install pytest
- name: Test with pytest
run: |
pytest tests/
- name: Build distribution
run: |
python setup.py sdist bdist_wheel
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: linux-build
path: dist/*.whl
deploy:
needs: build-linux
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: linux-build
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_HUB_USERNAME }}" --password-stdin
- name: Build and push Docker image
run: |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/my-app .
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/my-app
- name: Deploy to production
run: |
ssh user@your-server 'docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/ml-app && docker run -d -p 80:80 ${{ secrets.DOCKER_HUB_USERNAME }}/ml-app'