Skip to content

Commit abd3f90

Browse files
committed
Update fix
1 parent b05c2bc commit abd3f90

File tree

7 files changed

+47
-28
lines changed

7 files changed

+47
-28
lines changed

.github/workflows/ci-sonar.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Set up JDK 21
2323
uses: actions/setup-java@v5
2424
with:
25-
distribution: 'temurin'
25+
distribution: temurin
2626
java-version: '21'
2727
cache: maven
2828
server-id: github
@@ -45,22 +45,16 @@ jobs:
4545
- name: Set up JDK 21
4646
uses: actions/setup-java@v4
4747
with:
48-
distribution: temurin
48+
distribution: 'temurin'
4949
java-version: '21'
5050
cache: maven
51-
server-id: github
51+
server-id: 'github'
52+
server-username: 'GITHUB_ACTOR'
53+
server-password: '${{ secrets.GITHUB_TOKEN }}'
5254
settings-path: ${{ github.workspace }}
53-
token: ${{ secrets.GITHUB_TOKEN }}
5455

5556
- name: Publish to GitHub Packages
5657
if: startsWith(github.ref, 'refs/tags/v')
57-
run: |
58-
mvn -B -DskipTests=true -s $GITHUB_WORKSPACE/settings.xml deploy
59-
60-
- name: Publish to GitHub Packages
61-
if: startsWith(github.ref, 'refs/tags/v')
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6458
run: |
6559
# actions/setup-java (bên trên) đã tạo sẵn serverId=github dùng GITHUB_TOKEN
6660
mvn -B -DskipTests=true \

.github/workflows/coding-service-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
5555
IMAGE_TAG: ${{ env.IMAGE_TAG }}
5656
DOCKER_PLATFORMS: linux/amd64
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5758
run: |
5859
chmod +x ./build-image-coding-github.sh
5960
./build-image-coding-github.sh coding-service

.github/workflows/file-service-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
5555
IMAGE_TAG: ${{ env.IMAGE_TAG }}
5656
DOCKER_PLATFORMS: linux/amd64
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5758
run: |
5859
chmod +x ./build-image-file.sh
5960
./build-image-file.sh

build-image-coding-github.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DOCKERHUB_USER="${DOCKERHUB_USER:-yunomix2834}"
66
DOCKERHUB_TOKEN="${DOCKERHUB_TOKEN:-}"
77
IMAGE_TAG="${IMAGE_TAG:-$(date +%Y%m%d.%H%M%S)}"
88
DOCKER_PLATFORMS="${DOCKER_PLATFORMS:-linux/amd64}"
9+
GH_OWNER_LC="$(echo "${GITHUB_REPOSITORY_OWNER:-${GITHUB_REPOSITORY%%/*}}" | tr '[:upper:]' '[:lower:]')"
910

1011
# Xác định DOCKER_GID an toàn
1112
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
@@ -25,6 +26,13 @@ login() {
2526
else
2627
log "DOCKERHUB_TOKEN empty -> skip docker login (build will fail on --push if registry requires auth)"
2728
fi
29+
30+
if [ -n "${GITHUB_TOKEN:-}" ]; then
31+
log "Logging in GHCR as ${GITHUB_ACTOR:-github-actions}"
32+
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${GITHUB_ACTOR:-github-actions}" --password-stdin
33+
else
34+
log "GITHUB_TOKEN empty -> skip GHCR login"
35+
fi
2836
}
2937

3038
extra_tags_args() {
@@ -35,23 +43,27 @@ extra_tags_args() {
3543
args+=(-t "${repo}:${version}")
3644
fi
3745
if [ "${GITHUB_REF_NAME:-}" = "main" ]; then
38-
args+=(-t "${repo}:latest")
46+
args+=(-t "${repo}:latest}")
47+
args=("${args[@]::-1}" "-t" "${repo}:latest")
3948
fi
4049
printf '%s ' "${args[@]}"
4150
}
4251

4352
build_push_coding() {
4453
local module="${1:-coding-service}"
45-
local repo="${DOCKERHUB_USER}/codecampus-${module}"
54+
local repo_dh="${DOCKERHUB_USER}/codecampus-${module}"
55+
local repo_gh="ghcr.io/${GH_OWNER_LC}/codecampus-${module}"
4656

47-
log "Building coding-service with DOCKER_GID=${DOCKER_GID}"
57+
log "Building ${module} with DOCKER_GID=${DOCKER_GID}"
4858
docker buildx build \
4959
--platform "${DOCKER_PLATFORMS}" \
5060
-f docker/java-service-coding.Dockerfile \
5161
--build-arg "MODULE=${module}" \
5262
--build-arg "DOCKER_HOST_GID=${DOCKER_GID}" \
53-
-t "${repo}:${IMAGE_TAG}" \
54-
$(extra_tags_args "${repo}") \
63+
-t "${repo_dh}:${IMAGE_TAG}" \
64+
-t "${repo_gh}:${IMAGE_TAG}" \
65+
$(extra_tags_args "${repo_dh}") \
66+
$(extra_tags_args "${repo_gh}") \
5567
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}/$([ -n "${GITHUB_REPOSITORY:-}" ] && echo "${GITHUB_REPOSITORY}")" \
5668
--label "org.opencontainers.image.revision=${GITHUB_SHA:-}" \
5769
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \

build-image-file.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ DOCKERHUB_USER="${DOCKERHUB_USER:-yunomix2834}"
66
DOCKERHUB_TOKEN="${DOCKERHUB_TOKEN:-}"
77
IMAGE_TAG="${IMAGE_TAG:-$(date +%Y%m%d.%H%M%S)}"
88
DOCKER_PLATFORMS="${DOCKER_PLATFORMS:-linux/amd64}"
9+
GH_OWNER_LC="$(echo "${GITHUB_REPOSITORY_OWNER:-${GITHUB_REPOSITORY%%/*}}" | tr '[:upper:]' '[:lower:]')"
910

1011
log() { echo "[$(date +'%H:%M:%S')] $*"; }
1112

@@ -16,6 +17,13 @@ login() {
1617
else
1718
log "DOCKERHUB_TOKEN empty -> skip docker login (build will fail on --push if registry requires auth)"
1819
fi
20+
21+
if [ -n "${GITHUB_TOKEN:-}" ]; then
22+
log "Logging in GHCR as ${GITHUB_ACTOR:-github-actions}"
23+
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${GITHUB_ACTOR:-github-actions}" --password-stdin
24+
else
25+
log "GITHUB_TOKEN empty -> skip GHCR login"
26+
fi
1927
}
2028

2129
extra_tags_args() {
@@ -32,12 +40,16 @@ extra_tags_args() {
3240
}
3341

3442
build_push_file_service() {
35-
local repo="${DOCKERHUB_USER}/codecampus-file-service"
43+
local repo_dh="${DOCKERHUB_USER}/codecampus-file-service"
44+
local repo_gh="ghcr.io/${GH_OWNER_LC}/codecampus-file-service"
45+
3646
docker buildx build \
3747
--platform "${DOCKER_PLATFORMS}" \
3848
-f docker/file-service.Dockerfile \
39-
-t "${repo}:${IMAGE_TAG}" \
40-
$(extra_tags_args "${repo}") \
49+
-t "${repo_dh}:${IMAGE_TAG}" \
50+
-t "${repo_gh}:${IMAGE_TAG}" \
51+
$(extra_tags_args "${repo_dh}") \
52+
$(extra_tags_args "${repo_gh}") \
4153
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}/$([ -n "${GITHUB_REPOSITORY:-}" ] && echo "${GITHUB_REPOSITORY}")" \
4254
--label "org.opencontainers.image.revision=${GITHUB_SHA:-}" \
4355
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \

build-image-github.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DOCKERHUB_USER="${DOCKERHUB_USER:-yunomix2834}"
66
DOCKERHUB_TOKEN="${DOCKERHUB_TOKEN:-}"
77
IMAGE_TAG="${IMAGE_TAG:-$(date +%Y%m%d.%H%M%S)}"
88
DOCKER_PLATFORMS="${DOCKER_PLATFORMS:-linux/amd64}"
9-
GITHUB_OWNER="${GITHUB_OWNER:-${GITHUB_REPOSITORY_OWNER:-}}"
9+
GH_OWNER_LC="$(echo "${GITHUB_REPOSITORY_OWNER:-${GITHUB_REPOSITORY%%/*}}" | tr '[:upper:]' '[:lower:]')"
1010

1111
DEFAULT_SERVICES=(
1212
ai-service chat-service coding-service gateway-service identity-service
@@ -24,12 +24,11 @@ login() {
2424
log "DOCKERHUB_TOKEN empty -> skip docker login (build will fail on --push if registry requires auth)"
2525
fi
2626

27-
# Login GHCR bằng GITHUB_TOKEN
2827
if [ -n "${GITHUB_TOKEN:-}" ]; then
2928
log "Logging in GHCR as ${GITHUB_ACTOR:-github-actions}"
30-
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "${GITHUB_ACTOR:-github-actions}" --password-stdin
31-
else
32-
log "GITHUB_TOKEN empty -> skip GHCR login"
29+
echo "${GITHUB_TOKEN}" | docker login ghcr.io -u "${GITHUB_ACTOR:-github-actions}" --password-stdin
30+
else
31+
log "GITHUB_TOKEN empty -> skip GHCR login"
3332
fi
3433
}
3534

@@ -49,16 +48,16 @@ extra_tags_args() {
4948
build_push_java() {
5049
local module="$1"
5150
local repo="${DOCKERHUB_USER}/codecampus-${module}"
52-
local repo_ghcr="ghcr.io/${GITHUB_OWNER}/codecampus-${module}"
51+
local ghcr_repo="ghcr.io/${GH_OWNER_LC}/codecampus-${module}"
5352
log "Building Java service: ${module}"
5453
docker buildx build \
5554
--platform "${DOCKER_PLATFORMS}" \
5655
-f docker/java-service.Dockerfile \
5756
--build-arg "MODULE=${module}" \
5857
-t "${repo}:${IMAGE_TAG}" \
59-
-t "${repo_ghcr}:${IMAGE_TAG}" \
58+
-t "${ghcr_repo}:${IMAGE_TAG}" \
6059
$(extra_tags_args "${repo}") \
61-
$(extra_tags_args "${repo_ghcr}") \
60+
$(extra_tags_args "${ghcr_repo}") \
6261
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}/$([ -n "${GITHUB_REPOSITORY:-}" ] && echo "${GITHUB_REPOSITORY}")" \
6362
--label "org.opencontainers.image.revision=${GITHUB_SHA:-}" \
6463
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \

identity-service/src/main/resources/application-docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ management:
2424
app:
2525
services:
2626
profile: http://profile-service:8081/profile
27-
organization: http://organization-service:8091/org
27+
organization: http://organization-service:8092/org
2828
init:
2929
admin:
3030
username: ${INIT_ADMIN_USERNAME:}

0 commit comments

Comments
 (0)