Skip to content

Commit eccda4f

Browse files
Added meta Data
1 parent 942150f commit eccda4f

1 file changed

Lines changed: 41 additions & 23 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
#*********************************************************************/
2-
# CI Pipeline - Docker Orchestration & Image Distribution */
2+
# CI Pipeline - Docker Orchestration & Image Distribution */
33
# */
44
# Purpose : Packages the CaseConversionAPI ecosystem into */
55
# separate Backend and Frontend images for DockerHub. */
66
# Trigger : Push to main / Pull Request to main */
77
# Runtime : Ubuntu Latest */
88
# */
9-
# Notes : - Builds Backend from /backend/Dockerfile. */
10-
# - Builds Frontend from /frontend/Dockerfile. */
9+
# Notes : - Context set to root (.) to allow cross-repo access. */
10+
# - Builds Backend from /backend/Dockerfile. */
11+
# - Builds Frontend from /frontend/Dockerfile. */
1112
# - Requires DOCKER_USERNAME and DOCKER_PASSWORD secrets. */
1213
# */
1314
# Revision History: */
1415
# ------------------------------------------------------------------ */
15-
# Version Date Author Description */
16+
# Version Date Author Description */
1617
# ------------------------------------------------------------------ */
17-
# 1.0 2026-04-14 Nitish Singh Initial Docker Hub Workflow */
18-
# 1.1 2026-04-15 Nitish Singh Updated for Monorepo Paths */
18+
# 1.0 2026-04-14 Nitish Singh Initial Docker Hub Workflow */
19+
# 1.1 2026-04-15 Nitish Singh Updated for Monorepo Paths */
20+
# 1.2 2026-04-16 Nitish Singh Optimized Context & Metadata */
1921
#*********************************************************************/
2022

2123
name: Build and Push Docker Images
@@ -29,19 +31,16 @@ on:
2931
jobs:
3032
docker:
3133
runs-on: ubuntu-latest
32-
3334
steps:
3435
# ======================================================
3536
# 1. WORKSPACE PREPARATION
3637
# ======================================================
37-
3838
- name: Checkout repo
3939
uses: actions/checkout@v4
4040

4141
# ======================================================
4242
# 2. VIRTUALIZED BUILDER SETUP
4343
# ======================================================
44-
4544
- name: Set up Docker Buildx
4645
uses: docker/setup-buildx-action@v3
4746
with:
@@ -50,41 +49,60 @@ jobs:
5049
# ======================================================
5150
# 3. REGISTRY AUTHENTICATION
5251
# ======================================================
53-
5452
- name: Login to DockerHub
53+
if: github.event_name != 'pull_request'
5554
uses: docker/login-action@v3
5655
with:
5756
username: ${{ secrets.DOCKER_USERNAME }}
5857
password: ${{ secrets.DOCKER_PASSWORD }}
5958

6059
# ======================================================
61-
# 4. BACKEND: COMPILATION & DISTRIBUTION
60+
# 4. METADATA EXTRACTION (Automated Tagging)
6261
# ======================================================
62+
- name: Extract Backend Metadata
63+
id: meta_backend
64+
uses: docker/metadata-action@v5
65+
with:
66+
images: nitishhsinghhh/case-api
67+
tags: |
68+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
69+
type=raw,value=staging,enable=${{ github.ref == 'refs/heads/main' }}
70+
type=ref,event=pr
6371
72+
- name: Extract Frontend Metadata
73+
id: meta_frontend
74+
uses: docker/metadata-action@v5
75+
with:
76+
images: nitishhsinghhh/case-ui
77+
tags: |
78+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
79+
type=raw,value=staging,enable=${{ github.ref == 'refs/heads/main' }}
80+
type=ref,event=pr
81+
82+
# ======================================================
83+
# 5. BACKEND: COMPILATION & DISTRIBUTION
84+
# ======================================================
6485
- name: Build and Push Backend
6586
uses: docker/build-push-action@v5
6687
with:
67-
context: ./backend
88+
context: .
6889
file: ./backend/Dockerfile
69-
push: true
70-
tags: |
71-
nitishhsinghhh/case-api:latest
72-
nitishhsinghhh/case-api:staging
90+
push: ${{ github.event_name != 'pull_request' }}
91+
tags: ${{ steps.meta_backend.outputs.tags }}
92+
labels: ${{ steps.meta_backend.outputs.labels }}
7393
cache-from: type=gha
7494
cache-to: type=gha,mode=max
7595

7696
# ======================================================
77-
# 5. FRONTEND: COMPILATION & DISTRIBUTION
97+
# 6. FRONTEND: COMPILATION & DISTRIBUTION
7898
# ======================================================
79-
8099
- name: Build and Push Frontend
81100
uses: docker/build-push-action@v5
82101
with:
83-
context: ./frontend
102+
context: .
84103
file: ./frontend/Dockerfile
85-
push: true
86-
tags: |
87-
nitishhsinghhh/case-ui:latest
88-
nitishhsinghhh/case-ui:staging
104+
push: ${{ github.event_name != 'pull_request' }}
105+
tags: ${{ steps.meta_frontend.outputs.tags }}
106+
labels: ${{ steps.meta_frontend.outputs.labels }}
89107
cache-from: type=gha
90108
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)