Skip to content

Commit d74fce6

Browse files
committed
ci: separated latest
1 parent e4b34ba commit d74fce6

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

.github/workflows/main.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,30 @@ jobs:
5252
- name: Run tests
5353
run: poetry run pytest -v --cov=src
5454

55-
build-and-publish:
55+
docker-build-and-publish-latest:
5656
runs-on: ubuntu-24.04
5757
needs: test
58-
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
58+
if: github.ref == 'refs/heads/main'
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v4
62+
63+
- name: Log in to GitHub Container Registry
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ghcr.io
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Build and tag Docker image
71+
run: |
72+
docker build -t ghcr.io/${GITHUB_REPOSITORY,,}:latest .
73+
docker push ghcr.io/${GITHUB_REPOSITORY,,}:latest
74+
75+
docker-build-and-publish-tag:
76+
runs-on: ubuntu-24.04
77+
needs: test
78+
if: startsWith(github.ref, 'refs/tags/')
5979
steps:
6080
- name: Checkout repository
6181
uses: actions/checkout@v4
@@ -70,11 +90,7 @@ jobs:
7090
- name: Extract tag or sha
7191
id: vars
7292
run: |
73-
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
74-
VERSION="${GITHUB_REF#refs/tags/}"
75-
else
76-
VERSION="${GITHUB_SHA}"
77-
fi
93+
VERSION="${GITHUB_REF#refs/tags/}"
7894
IMAGE="ghcr.io/${GITHUB_REPOSITORY,,}:${VERSION}"
7995
echo "tag=${IMAGE}" >> $GITHUB_OUTPUT
8096
@@ -83,9 +99,3 @@ jobs:
8399

84100
- name: Push Docker image
85101
run: docker push ${{ steps.vars.outputs.tag }}
86-
87-
- name: Also tag and push :latest on main
88-
if: github.ref == 'refs/heads/main'
89-
run: |
90-
docker tag ${{ steps.vars.outputs.tag }} ghcr.io/${GITHUB_REPOSITORY,,}:latest
91-
docker push ghcr.io/${GITHUB_REPOSITORY,,}:latest

0 commit comments

Comments
 (0)