Skip to content

Build and Push Docker Image #6

Build and Push Docker Image

Build and Push Docker Image #6

name: Build and Push Docker Image
on:
workflow_dispatch:
inputs:
tag:
description: 'Docker image tag'
required: false
default: 'latest'
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and publish Docker image
run: |
cd docker
IMAGE_TAG=${{ github.event.inputs.tag || 'latest' }}
IMAGE_NAME=ghcr.io/${{ github.repository_owner }}/workshop:$IMAGE_TAG
docker build -t $IMAGE_NAME .
docker push $IMAGE_NAME