Skip to content

Build and Publish Docker Image #6

Build and Publish Docker Image

Build and Publish Docker Image #6

Workflow file for this run

name: Build and Publish Docker Image
on:
push:
tags:
- 'release*'
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Set up Docker image name
# id: vars
# run: echo "IMAGE_NAME=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
- name: Prepare Docker image name and tag
run: |
# Force lowercase for repository name
REPO_NAME=$(basename "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')
# Use raw tag name (e.g., release_test_1.0), also force lowercase if needed
IMAGE_TAG=$(echo "${GITHUB_REF_NAME}" | tr '[:upper:]' '[:lower:]')
echo "IMAGE_NAME=${REPO_NAME}" >> $GITHUB_ENV
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
- name: Build Docker image
run: docker build -t $IMAGE_NAME:$IMAGE_TAG .
- name: Push Docker image
run: docker push $IMAGE_NAME:$IMAGE_TAG