Skip to content

Build & Push (GHCR)

Build & Push (GHCR) #5

Workflow file for this run

name: Build & Push (GHCR)
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout (with tags)
uses: actions/checkout@v4
with:
fetch-depth: 0 # NECESAR pentru git tag
- uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine image tag
id: ver
shell: bash
run: |
set -e
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
TAG="${GITHUB_REF#refs/tags/}"
else
TAG="$(git tag --list 'v*' | sort -V | tail -n 1)"
if [ -z "$TAG" ]; then
TAG="manual-${GITHUB_SHA::7}"
fi
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Using tag: $TAG"
- name: Build & Push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/serversmonitoring:${{ steps.ver.outputs.tag }}