1 Commits
v6 ... v3

Author SHA1 Message Date
abbaf884fd move habor to docker.io 2026-02-09 14:45:46 +07:00

View File

@@ -1,14 +1,18 @@
name: Harbor Build Once → Deploy Many (Compose) name: Docker Build Once → Deploy Many (Compose)
on: on:
workflow_call: workflow_call:
inputs: inputs:
harbor_registry: docker_registry:
description: Registry host (docker.io, ghcr.io, registry.example.com)
type: string type: string
default: harbor.hcmc.online default: docker.io
harbor_project:
docker_namespace:
description: Docker namespace / org / username
type: string type: string
default: ci required: true
image_repo: image_repo:
type: string type: string
required: true required: true
@@ -23,9 +27,8 @@ on:
type: string type: string
default: linux/amd64,linux/arm64 default: linux/amd64,linux/arm64
# IMPORTANT CHANGE
deploy_runners_json: deploy_runners_json:
description: 'JSON array of runner labels' description: JSON array of runner labels
type: string type: string
required: true required: true
@@ -37,10 +40,8 @@ on:
default: up -d --pull always --remove-orphans default: up -d --pull always --remove-orphans
secrets: secrets:
HARBOR_PUSH_USERNAME: { required: true } DOCKER_HUB_USERNAME: { required: true }
HARBOR_PUSH_PASSWORD: { required: true } DOCKER_HUB_ACCESS_TOKEN: { required: true }
HARBOR_PULL_USERNAME: { required: true }
HARBOR_PULL_PASSWORD: { required: true }
jobs: jobs:
@@ -48,7 +49,7 @@ jobs:
# BUILD ONCE (single powerful runner) # BUILD ONCE (single powerful runner)
# ========================================================== # ==========================================================
build_and_push: build_and_push:
name: Build & Push Image name: Build & Push Image
runs-on: devsg-atlantic runs-on: devsg-atlantic
outputs: outputs:
@@ -65,7 +66,7 @@ jobs:
shell: bash shell: bash
run: | run: |
set -euo pipefail set -euo pipefail
IMAGE="${{ inputs.harbor_registry }}/${{ inputs.harbor_project }}/${{ inputs.image_repo }}" IMAGE="${{ inputs.docker_registry }}/${{ inputs.docker_namespace }}/${{ inputs.image_repo }}"
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-12) SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-12)
BRANCH="${{ github.ref_name }}" BRANCH="${{ github.ref_name }}"
@@ -73,14 +74,13 @@ jobs:
echo "sha_tag=sha-$SHORT_SHA" >> $GITHUB_OUTPUT echo "sha_tag=sha-$SHORT_SHA" >> $GITHUB_OUTPUT
echo "branch_tag=$BRANCH" >> $GITHUB_OUTPUT echo "branch_tag=$BRANCH" >> $GITHUB_OUTPUT
- name: Login Harbor (push) - name: Login Registry (push)
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ inputs.harbor_registry }} registry: ${{ inputs.docker_registry }}
username: ${{ secrets.HARBOR_PUSH_USERNAME }} username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.HARBOR_PUSH_PASSWORD }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# Cached multi-platform build
- name: Build & Push Image - name: Build & Push Image
id: build id: build
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
@@ -103,7 +103,7 @@ jobs:
# DEPLOY MANY (fan-out runners) # DEPLOY MANY (fan-out runners)
# ========================================================== # ==========================================================
deploy: deploy:
name: Deploy to Fleet name: Deploy to Fleet
needs: build_and_push needs: build_and_push
strategy: strategy:
@@ -116,17 +116,16 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Login Harbor (pull) - name: Login Registry (pull)
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ inputs.harbor_registry }} registry: ${{ inputs.docker_registry }}
username: ${{ secrets.HARBOR_PULL_USERNAME }} username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.HARBOR_PULL_PASSWORD }} password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Show image - name: Show image
run: echo "Deploying ${{ needs.build_and_push.outputs.image_ref }}" run: echo "Deploying ${{ needs.build_and_push.outputs.image_ref }}"
# Linux/macOS
- name: Compose Up (Unix) - name: Compose Up (Unix)
if: runner.os != 'Windows' if: runner.os != 'Windows'
shell: bash shell: bash
@@ -137,7 +136,6 @@ jobs:
set -euo pipefail set -euo pipefail
docker compose ${{ inputs.compose_args }} docker compose ${{ inputs.compose_args }}
# Windows runners support
- name: Compose Up (Windows) - name: Compose Up (Windows)
if: runner.os == 'Windows' if: runner.os == 'Windows'
shell: pwsh shell: pwsh
@@ -145,4 +143,4 @@ jobs:
env: env:
DOCKER_IMAGE: ${{ needs.build_and_push.outputs.image_ref }} DOCKER_IMAGE: ${{ needs.build_and_push.outputs.image_ref }}
run: | run: |
docker compose ${{ inputs.compose_args }} docker compose ${{ inputs.compose_args }}