Skip to content

Commit 9393f8f

Browse files
ci: push image for tags only
1 parent d6b8d4f commit 9393f8f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/build-and-push-image.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
name: CI
2-
on: [push]
1+
name: Build and push image
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
37

48
jobs:
59
build-and-push-image:
@@ -14,10 +18,15 @@ jobs:
1418
registry: ghcr.io
1519
username: ${{ github.actor }}
1620
password: ${{ secrets.GITHUB_TOKEN }}
21+
- name: Extract version
22+
run: |
23+
echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
24+
echo $VERSION
1725
- name: Build and push image
1826
run: |
1927
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
2028
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
2129
echo $IMAGE_ID
2230
docker build . -t ${IMAGE_ID}
31+
docker push ${IMAGE_ID}:${VERSION}
2332
docker push ${IMAGE_ID}:latest

0 commit comments

Comments
 (0)