Skip to content

Commit cf1aa2f

Browse files
committed
ci: added building of docker images
1 parent dc00884 commit cf1aa2f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,33 @@ jobs:
4848
run: poetry run mypy .
4949
- name: Run tests
5050
run: poetry run pytest -v --cov=src
51+
build-and-publish:
52+
runs-on: ubuntu-24.04
53+
needs: test # Ensures tests pass before publishing
54+
if: github.event_name != 'pull_request'
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Log in to GitHub Container Registry
60+
uses: docker/login-action@v3
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
66+
- name: Set image tag
67+
id: vars
68+
run: echo "tag=ghcr.io/${{ github.repository }}:${{ github.sha }}" >> $GITHUB_OUTPUT
69+
70+
- name: Build and tag Docker image
71+
run: docker build -t ${{ steps.vars.outputs.tag }} .
72+
73+
- name: Push Docker image
74+
run: docker push ${{ steps.vars.outputs.tag }}
75+
76+
- name: Tag and push latest (on main only)
77+
if: github.ref == 'refs/heads/main'
78+
run: |
79+
docker tag ${{ steps.vars.outputs.tag }} ghcr.io/${{ github.repository }}:latest
80+
docker push ghcr.io/${{ github.repository }}:latest

0 commit comments

Comments
 (0)