Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,59 @@
name: Build & Push Notification Service Docker Image
name: Ricash CI - Build & Push Docker Image

on:
pull_request:
branches: [ develop, main ]
push:
branches: ["main"]
branches: [ develop, main ]

permissions:
contents: read
packages: write

env:
REGISTRY: ghcr.io
ORG: ricash-org
SERVICE_NAME: notification-service
IMAGE_NAME: ghcr.io/ricash-org/notification-service

jobs:
build:
runs-on: ubuntu-latest

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

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
uses: actions/checkout@v4

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

# 🔐 Login GHCR
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & Push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
tags: ghcr.io/ricash-org/notification-service:latest
# 🧪 PR → build only (no push)
- name: Build Docker image (PR)
if: github.event_name == 'pull_request'
run: |
docker build \
-t $IMAGE_NAME:pr-${{ github.event.pull_request.number }} \
.

# 🚀 develop → push dev
- name: Build & Push (develop)
if: github.ref == 'refs/heads/develop'
run: |
docker build -t $IMAGE_NAME:dev .
docker push $IMAGE_NAME:dev

# 🚀 main → push prod (sha)
- name: Build & Push (main)
if: github.ref == 'refs/heads/main'
run: |
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
docker build -t $IMAGE_NAME:sha-$SHORT_SHA .
docker push $IMAGE_NAME:sha-$SHORT_SHA