11---
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-
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+ - name : Checkout repository
15+ uses : actions/checkout@v4
16+ - name : Set up Docker Buildx
17+ uses : docker/setup-buildx-action@v3
18+ - name : Log in to GitHub Container Registry
19+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }}
20+ --password-stdin
21+ - name : Extract version from pyproject.toml
22+ id : get_version
23+ run : |
24+ VERSION=$(grep '^current_version' pyproject.toml | head -n 1 | cut -d '"' -f2)
25+ echo "VERSION=$VERSION" >> $GITHUB_ENV
26+ - name : Build and push Docker image
27+ run : |
28+ docker buildx build \
29+ --push \
30+ --tag ghcr.io/${{ github.repository }}:latest \
31+ --tag ghcr.io/${{ github.repository }}:${{ github.sha }} \
32+ --tag ghcr.io/${{ github.repository }}:${{ env.VERSION }} \
33+ .
0 commit comments