Skip to content

Commit

Permalink
build docker image workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
githubofkrishnadhas committed Feb 13, 2024
1 parent 2e96bad commit 57ca380
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build_and_push_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and Push Docker Image

on:
workflow_dispatch:
inputs:
image_name:
description: 'Docker image name'
type: string
required: true
default: 'app'
tag:
description: 'Docker image tag'
type: string
required: true
default: 'latest'
push_to_dockerhub:
description: 'Whether we need to push the image to dockerhub'
type: boolean
required: true
dockerfile_path:
description: 'Dockerfile path'
type: string
default: '.'
required: true

run-name: building image ${{ inputs.image_name }}/${{ inputs.tag }}
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ${{ inputs.dockerfile_path }}
push: ${{ inputs.push_to_dockerhub }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ inputs.image_name }}:${{ inputs.tag }}

- name: Build completed
use: echo "Image build completed"

0 comments on commit 57ca380

Please sign in to comment.