-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e96bad
commit 57ca380
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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" |