-
Notifications
You must be signed in to change notification settings - Fork 4
55 lines (48 loc) · 1.45 KB
/
deploy-dockerhub.yml
File metadata and controls
55 lines (48 loc) · 1.45 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
name: Deploy To DockerHub
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
workflow_dispatch:
jobs:
dockerhub-deploy:
runs-on: ubuntu-latest
environment: dockerhub
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Extract version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "
try:
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
print(data['project']['version'])
except Exception as e:
print(f'Error reading version: {e}', file=sys.stderr)
exit(1)
")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/photomapai:${{ steps.get_version.outputs.version }}
${{ secrets.DOCKERHUB_USERNAME }}/photomapai:latest