Build & Push (GHCR) #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} |