new publish
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 6m25s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 6m25s
This commit is contained in:
parent
5b0243ab93
commit
0bea8c6e0b
@ -2,46 +2,44 @@ name: Build and Publish Docker Image
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches:
|
||||||
tags: ['*'] # triggers on any tag push
|
- main
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v5
|
||||||
|
with:
|
||||||
|
images: ${{ secrets.REGISTRY }}/${{ secrets.USERNAME }}/ktv-ui
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
type=semver,pattern={{major}}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Docker Registry
|
- name: Login to Docker Registry
|
||||||
run: echo "${{ secrets.PASSWORD }}" | docker login ${{ secrets.REGISTRY }} -u "${{ secrets.USERNAME }}" --password-stdin
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ secrets.REGISTRY }}
|
||||||
|
username: ${{ secrets.USERNAME }}
|
||||||
|
password: ${{ secrets.PASSWORD }}
|
||||||
|
|
||||||
- name: Build and Push Docker Images
|
- name: Build and push
|
||||||
run: |
|
uses: docker/build-push-action@v5
|
||||||
IMAGE_NAME="ktv-ui"
|
with:
|
||||||
REGISTRY="${{ secrets.REGISTRY }}"
|
context: .
|
||||||
USERNAME="${{ secrets.USERNAME }}"
|
push: true
|
||||||
IMAGE_LATEST="$REGISTRY/$USERNAME/$IMAGE_NAME:latest"
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
# Always build and tag as latest
|
|
||||||
echo "🔧 Building $IMAGE_LATEST"
|
|
||||||
docker build -t $IMAGE_LATEST .
|
|
||||||
|
|
||||||
echo "📤 Pushing $IMAGE_LATEST"
|
|
||||||
docker push $IMAGE_LATEST
|
|
||||||
|
|
||||||
# If this is a tag push, tag the image accordingly
|
|
||||||
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
|
||||||
GIT_TAG="${GITHUB_REF#refs/tags/}"
|
|
||||||
IMAGE_TAGGED="$REGISTRY/$USERNAME/$IMAGE_NAME:$GIT_TAG"
|
|
||||||
|
|
||||||
echo "🏷️ Also tagging as $IMAGE_TAGGED"
|
|
||||||
docker tag $IMAGE_LATEST $IMAGE_TAGGED
|
|
||||||
|
|
||||||
echo "📤 Pushing $IMAGE_TAGGED"
|
|
||||||
docker push $IMAGE_TAGGED
|
|
||||||
fi
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user