Skip to content

Commit 0c8bc74

Browse files
committed
Update Dependabot
1 parent 388bd91 commit 0c8bc74

File tree

6 files changed

+99
-30
lines changed

6 files changed

+99
-30
lines changed

.github/dependabot.yml

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
version: 2
2+
registries:
3+
ghcr:
4+
type: docker-registry
5+
url: ghcr.io
6+
username: ${{secrets.GHCR_USERNAME}}
7+
password: ${{secrets.GHCR_TOKEN}}
8+
9+
dockerhub:
10+
type: docker-registry
11+
url: registry-1.docker.io
12+
username: ${{secrets.DOCKERHUB_USER}}
13+
password: ${{secrets.DOCKERHUB_TOKEN}}
14+
15+
github-maven:
16+
type: maven-repository
17+
url: https://maven.pkg.github.com/${{github.repository_owner}}/*
18+
username: ${{secrets.GHCR_USERNAME}}
19+
password: ${{secrets.GHCR_TOKEN}}
220
updates:
321
# Dependabot maven có thể chạy ở root của multi-module project
422
- package-ecosystem: "maven"
@@ -12,25 +30,16 @@ updates:
1230
labels: [ "dependencies", "maven", "backend" ]
1331
groups:
1432
spring-bom:
15-
patterns:
16-
- "org.springframework.boot:*"
17-
- "org.springframework.cloud:*"
33+
patterns: [ "org.springframework.boot:*", "org.springframework.cloud:*" ]
1834
update-types: [ "minor", "patch" ]
1935
grpc-protobuf:
20-
patterns:
21-
- "io.grpc:*"
22-
- "com.google.protobuf:*"
36+
patterns: [ "io.grpc:*", "com.google.protobuf:*" ]
2337
update-types: [ "minor", "patch" ]
2438
mapping-and-utils:
25-
patterns:
26-
- "org.projectlombok:*"
27-
- "org.mapstruct:*"
39+
patterns: [ "org.projectlombok:*", "org.mapstruct:*" ]
2840
update-types: [ "minor", "patch" ]
2941
test-stack:
30-
patterns:
31-
- "org.jacoco:*"
32-
- "org.sonarsource.scanner.maven:sonar-maven-plugin"
33-
- "org.apache.maven.plugins:*"
42+
patterns: [ "org.jacoco:*", "org.sonarsource.scanner.maven:sonar-maven-plugin", "org.apache.maven.plugins:*" ]
3443
update-types: [ "minor", "patch" ]
3544

3645
# ========= FileService (.NET / NuGet) =========
@@ -57,19 +66,11 @@ updates:
5766
labels: [ "dependencies", "docker" ]
5867
open-pull-requests-limit: 10
5968
groups:
60-
nginx-node-base:
61-
patterns:
62-
- "nginx"
63-
- "node"
64-
update-types: [ "minor", "patch" ]
6569
dotnet-base:
66-
patterns:
67-
- "mcr.microsoft.com/dotnet/*"
70+
patterns: [ "mcr.microsoft.com/dotnet/*" ]
6871
update-types: [ "minor", "patch" ]
6972
jre-maven:
70-
patterns:
71-
- "eclipse-temurin:*"
72-
- "maven:*"
73+
patterns: [ "eclipse-temurin:*", "maven:*" ]
7374
update-types: [ "minor", "patch" ]
7475

7576
# ========= Dockerfiles ở root =========
@@ -87,6 +88,7 @@ updates:
8788
# ========= GitHub Actions =========
8889
- package-ecosystem: "github-actions"
8990
directory: "/"
91+
registries: [ "ghcr", "dockerhub" ]
9092
schedule:
9193
interval: "weekly"
9294
day: "monday"

.github/workflows/ci-sonar.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ jobs:
3939
**/target/failsafe-reports/**
4040
if-no-files-found: ignore
4141

42+
- name: Set up JDK 21
43+
uses: actions/setup-java@v4
44+
with:
45+
distribution: temurin
46+
java-version: '21'
47+
cache: maven
48+
server-id: github
49+
settings-path: ${{ github.workspace }}
50+
token: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Publish to GitHub Packages
53+
if: startsWith(github.ref, 'refs/tags/v')
54+
run: |
55+
mvn -B -DskipTests=true -s $GITHUB_WORKSPACE/settings.xml deploy
56+
4257
- name: SonarQube / SonarCloud Scan
4358
env:
4459
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN_BACKEND }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Dependabot Auto-merge (minor & patch)
2+
3+
on:
4+
pull_request_target:
5+
types: [ opened, synchronize, reopened, labeled ]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
checks: read
11+
12+
jobs:
13+
auto-merge:
14+
if: github.actor == 'dependabot[bot]'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Fetch metadata
18+
id: meta
19+
uses: dependabot/fetch-metadata@v2
20+
with:
21+
github-token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Approve PR (minor/patch)
24+
if: |
25+
steps.meta.outputs.update-type == 'version-update:semver-minor' ||
26+
steps.meta.outputs.update-type == 'version-update:semver-patch'
27+
uses: peter-evans/approve-pull-request@v6
28+
with:
29+
pull-request-number: ${{ github.event.pull_request.number }}
30+
review-message: "Auto-approved by workflow for minor/patch updates."
31+
32+
- name: Enable auto-merge (squash)
33+
if: |
34+
steps.meta.outputs.update-type == 'version-update:semver-minor' ||
35+
steps.meta.outputs.update-type == 'version-update:semver-patch'
36+
uses: peter-evans/enable-pull-request-automerge@v3
37+
with:
38+
pull-request-number: ${{ github.event.pull_request.number }}
39+
merge-method: squash

build-image-github.sh

Lines changed: 12 additions & 0 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+
GITHUB_OWNER="${GITHUB_OWNER:-${GITHUB_REPOSITORY_OWNER:-}}"
910

1011
DEFAULT_SERVICES=(
1112
ai-service chat-service coding-service gateway-service identity-service
@@ -22,6 +23,14 @@ login() {
2223
else
2324
log "DOCKERHUB_TOKEN empty -> skip docker login (build will fail on --push if registry requires auth)"
2425
fi
26+
27+
# Login GHCR bằng GITHUB_TOKEN
28+
if [ -n "${GITHUB_TOKEN:-}" ]; then
29+
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"
33+
fi
2534
}
2635

2736
extra_tags_args() {
@@ -40,13 +49,16 @@ extra_tags_args() {
4049
build_push_java() {
4150
local module="$1"
4251
local repo="${DOCKERHUB_USER}/codecampus-${module}"
52+
local repo_ghcr="ghcr.io/${GITHUB_OWNER}/codecampus-${module}"
4353
log "Building Java service: ${module}"
4454
docker buildx build \
4555
--platform "${DOCKER_PLATFORMS}" \
4656
-f docker/java-service.Dockerfile \
4757
--build-arg "MODULE=${module}" \
4858
-t "${repo}:${IMAGE_TAG}" \
59+
-t "${repo_ghcr}:${IMAGE_TAG}" \
4960
$(extra_tags_args "${repo}") \
61+
$(extra_tags_args "${repo_ghcr}") \
5062
--label "org.opencontainers.image.source=${GITHUB_SERVER_URL:-}/$([ -n "${GITHUB_REPOSITORY:-}" ] && echo "${GITHUB_REPOSITORY}")" \
5163
--label "org.opencontainers.image.revision=${GITHUB_SHA:-}" \
5264
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \

docker-compose.prod-services.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,6 @@ services:
220220
- chat-service
221221
networks: [ backend ]
222222

223-
frontend:
224-
image: ${DOCKERHUB_USER}/codecampus-frontend:${IMAGE_TAG:-latest}
225-
restart: unless-stopped
226-
ports: [ "4200:80" ]
227-
networks: [ backend ]
228-
229-
230223
########################
231224
# NETWORK & VOLUME #
232225
########################

pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@
113113
</dependencies>
114114
</dependencyManagement>
115115

116+
<distributionManagement>
117+
<repository>
118+
<id>github</id>
119+
<name>GitHub Packages</name>
120+
<url>https://maven.pkg.github.com/${project.groupId}/${project.artifactId}</url>
121+
</repository>
122+
</distributionManagement>
123+
116124
<!-- Quản lý version plugin dùng chung -->
117125
<build>
118126
<pluginManagement>

0 commit comments

Comments
 (0)