Smiel2's picture
Initial commit
2eae977 verified
Raw
History Blame Contribute Delete
1.93 kB
name: Build and Push Docker Image
on:
workflow_dispatch:
inputs:
tag:
description: 'Docker image tag'
required: true
default: 'latest'
push_to_hub:
description: 'Push to Docker Hub'
type: boolean
default: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event.inputs.push_to_hub == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
smart-line-bot
ghcr.io/${{ github.repository }}
tags: |
${{ github.event.inputs.tag }}
latest
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event.inputs.push_to_hub == 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry
cache-to: type=inline
build-args: |
BUILD_DATE=${{ github.event.inputs.tag }}
VERSION=${{ github.event.inputs.tag }}
- name: Update GitHub Release
if: github.event.inputs.push_to_hub == 'true'
run: |
echo "Docker image built and pushed successfully"
echo "Image: smart-line-bot:${{ github.event.inputs.tag }}"