Skip to content

ci: push image for tags only #16

ci: push image for tags only

ci: push image for tags only #16

name: Build and push image
on:
push:
tags:
- "v*"
jobs:
build-and-push-image:
runs-on: ubuntu-latest
env:
IMAGE_NAME: "oc4ids-datastore-pipeline"
steps:
- uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version
run: |
TAG=${GITHUB_REF#refs/*/}
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Print version
run: echo $VERSION
- name: Build and push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo $IMAGE_ID
docker build . -t ${IMAGE_ID}:${VERSION} -t ${IMAGE_ID}:latest
docker push ${IMAGE_ID}:${VERSION}
docker push ${IMAGE_ID}:latest