Skip to content

Commit 91d46e9

Browse files
committed
Updating docker build to better tagging
1 parent 197076b commit 91d46e9

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed
Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
11
---
2-
name: Build and Push Docker Image
3-
on:
4-
push:
5-
branches: [main]
6-
workflow_dispatch:
7-
permissions:
8-
contents: read
9-
packages: write
10-
jobs:
11-
build-and-push-docker-image:
12-
runs-on: ubuntu-latest
13-
steps:
14-
- uses: actions/checkout@v4
15-
- name: Log in to GitHub Container Registry
16-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u github.actor
17-
}} --password-stdin
18-
- name: Build and push
19-
run: |-
20-
docker build -t ghcr.io/${{ github.repository }}:latest .
21-
docker push ghcr.io/${{ github.repository }}:latest
2+
name: Build and Push Docker Image
3+
4+
on:
5+
push:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
13+
jobs:
14+
build-and-push-docker-image:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Log in to GitHub Container Registry
24+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
25+
26+
- name: Extract version from pyproject.toml
27+
id: get_version
28+
run: |
29+
VERSION=$(grep '^current_version' pyproject.toml | head -n 1 | cut -d '"' -f2)
30+
echo "VERSION=$VERSION" >> $GITHUB_ENV
31+
32+
- name: Build and push Docker image
33+
run: |
34+
docker buildx build \
35+
--push \
36+
--tag ghcr.io/${{ github.repository }}:latest \
37+
--tag ghcr.io/${{ github.repository }}:${{ github.sha }} \
38+
--tag ghcr.io/${{ github.repository }}:${{ env.VERSION }} \
39+
.
40+
41+

0 commit comments

Comments
 (0)