Skip to content

Commit cd1e63f

Browse files
committed
ci: add Docker Hub publish workflow
1 parent 66aedbe commit cd1e63f

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: CI
33
on:
44
push:
55
branches: [ "main" ]
6+
tags:
7+
- "v*"
68
pull_request:
79
branches: [ "main" ]
810

@@ -18,26 +20,19 @@ jobs:
1820
with:
1921
python-version: "3.12"
2022

21-
- name: Install project and dev deps
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install -e ".[dev]"
25-
# tools (explicit, in case dev extras change)
26-
pip install ruff black pytest
23+
- name: Install (dev)
24+
run: make dev
2725

28-
- name: Ruff (lint)
29-
run: ruff check .
26+
- name: Lint
27+
run: make lint
3028

31-
- name: Black (format check)
32-
run: black --check .
33-
34-
- name: Pytest
35-
run: pytest -q
29+
- name: Test
30+
run: make test
3631

3732
docker-build:
3833
runs-on: ubuntu-latest
3934
needs: test
40-
if: github.event_name == 'push' # build only on push, not PR
35+
if: github.event_name == 'push'
4136
steps:
4237
- name: Checkout
4338
uses: actions/checkout@v4
@@ -50,6 +45,34 @@ jobs:
5045
with:
5146
context: .
5247
file: ./Dockerfile
53-
tags: mvtk/sysinfo-cli:ci
48+
tags: sysinfo-cli:ci
5449
load: true
5550

51+
publish:
52+
runs-on: ubuntu-latest
53+
needs: docker-build
54+
if: startsWith(github.ref, 'refs/tags/')
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Docker Buildx
60+
uses: docker/setup-buildx-action@v3
61+
62+
- name: Login to Docker Hub
63+
uses: docker/login-action@v3
64+
with:
65+
username: ${{ secrets.DOCKERHUB_USERNAME }}
66+
password: ${{ secrets.DOCKERHUB_TOKEN }}
67+
68+
- name: Build and Push to Docker Hub
69+
uses: docker/build-push-action@v6
70+
with:
71+
context: .
72+
file: ./Dockerfile
73+
push: true
74+
tags: |
75+
mircothibes/sysinfo-cli:latest
76+
mircothibes/sysinfo-cli:${{ github.ref_name }}
77+
78+

0 commit comments

Comments
 (0)