Skip to content

Commit 984d33e

Browse files
committed
Move to GHCR
1 parent ee5ca31 commit 984d33e

File tree

3 files changed

+94
-80
lines changed

3 files changed

+94
-80
lines changed

.github/workflows/backend.yaml

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
1-
name: Cupcake Backend
1+
name: Build Cupcake
22

33
on:
44
push:
5+
branches:
6+
- main
7+
tags-ignore:
8+
- '**'
59
paths:
610
- backend/**
711
- .github/workflows/backend.yaml
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
packages: write
817

918
jobs:
1019
push:
11-
name: "Build Cupcake backend"
1220
runs-on: ubuntu-latest
1321

14-
env:
15-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
16-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
17-
1822
steps:
1923
- name: Checkout
20-
uses: actions/checkout@v4
24+
uses: actions/checkout@v5
2125

2226
- name: Set up JDK
23-
uses: actions/setup-java@v4
27+
uses: actions/setup-java@v5
2428
with:
2529
java-version: '22'
2630
distribution: 'temurin'
@@ -34,37 +38,46 @@ jobs:
3438

3539
- name: Set up QEMU
3640
uses: docker/setup-qemu-action@v3
37-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
3841

3942
- name: Set up Docker Buildx
4043
uses: docker/setup-buildx-action@v3
41-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
4244

43-
- name: Login to DockerHub Registry
45+
- name: Login to GHCR
4446
uses: docker/login-action@v3
4547
with:
46-
username: ${{ env.DOCKERHUB_USERNAME }}
47-
password: ${{ env.DOCKERHUB_TOKEN }}
48-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ github.token }}
4951

5052
- name: Build and push
51-
uses: docker/build-push-action@v5
53+
uses: docker/build-push-action@v6
5254
with:
5355
context: ./backend
5456
platforms: linux/amd64,linux/arm64
5557
push: true
56-
tags: "${{ env.DOCKERHUB_USERNAME }}/cupcake:${{ github.sha }},${{ env.DOCKERHUB_USERNAME }}/cupcake:latest"
57-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
58+
tags: |
59+
ghcr.io/javabin/cupcake:${{ github.sha }}
60+
ghcr.io/javabin/cupcake:latest
61+
labels: |
62+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
5863
5964
- name: Create staging
60-
if: ${{ github.ref == 'refs/heads/main' && env.DOCKERHUB_USERNAME != '' }}
61-
run: docker buildx imagetools create -t ${{ env.DOCKERHUB_USERNAME }}/cupcake:staging ${{ env.DOCKERHUB_USERNAME }}/cupcake:latest
65+
if: github.ref == 'refs/heads/main'
66+
run: |
67+
docker buildx imagetools create \
68+
--tag ghcr.io/javabin/cupcake:staging \
69+
ghcr.io/javabin/cupcake:latest
70+
71+
- name: Generate summary
72+
run: |
73+
echo "Tag: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
74+
working-directory: backend
6275

6376
- name: Upload reports if failed
6477
if: failure()
6578
uses: actions/upload-artifact@v4
6679
with:
67-
name: search-reports
80+
name: cupcake-reports
6881
path: |
6982
backend/**/build/reports/
7083
backend/**/build/test-results/
@@ -73,12 +86,6 @@ jobs:
7386
if: success()
7487
uses: actions/upload-artifact@v4
7588
with:
76-
name: search-coverage
89+
name: cupcake-coverage
7790
path: |
7891
backend/**/build/reports/jacoco/
79-
80-
- name: Generate summary
81-
run: |
82-
echo "Tag: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
83-
working-directory: backend
84-

.github/workflows/frontend.yaml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,61 @@
1-
name: Frosting Frontend
1+
name: Build Frosting
22

33
on:
44
push:
5+
branches:
6+
- main
7+
tags-ignore:
8+
- '**'
59
paths:
610
- frontend/**
711
- .github/workflows/frontend.yaml
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
packages: write
817

918
jobs:
1019
push:
11-
name: "Build Frosting frontend"
1220
runs-on: ubuntu-latest
1321

14-
env:
15-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
16-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
17-
1822
steps:
1923
- name: Checkout
20-
uses: actions/checkout@v4
24+
uses: actions/checkout@v5
2125

2226
- name: Set up QEMU
2327
uses: docker/setup-qemu-action@v3
24-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
2528

2629
- name: Set up Docker Buildx
2730
uses: docker/setup-buildx-action@v3
28-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
2931

30-
- name: Login to DockerHub Registry
32+
- name: Login to GHCR
3133
uses: docker/login-action@v3
3234
with:
33-
username: ${{ env.DOCKERHUB_USERNAME }}
34-
password: ${{ env.DOCKERHUB_TOKEN }}
35-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
35+
registry: ghcr.io
36+
username: ${{ github.actor }}
37+
password: ${{ github.token }}
3638

3739
- name: Build and push
38-
uses: docker/build-push-action@v5
40+
uses: docker/build-push-action@v6
3941
with:
4042
context: ./frontend
4143
platforms: linux/amd64,linux/arm64
4244
push: true
43-
tags: "${{ env.DOCKERHUB_USERNAME }}/frosting:${{ github.sha }},${{ env.DOCKERHUB_USERNAME }}/frosting:latest"
44-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
45+
tags: |
46+
ghcr.io/javabin/frosting:${{ github.sha }}
47+
ghcr.io/javabin/frosting:latest
48+
labels: |
49+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
4550
4651
- name: Create staging
47-
if: ${{ github.ref == 'refs/heads/main' && env.DOCKERHUB_USERNAME != '' }}
48-
run: docker buildx imagetools create -t ${{ env.DOCKERHUB_USERNAME }}/frosting:staging ${{ env.DOCKERHUB_USERNAME }}/frosting:latest
52+
if: github.ref == 'refs/heads/main'
53+
run: |
54+
docker buildx imagetools create \
55+
--tag ghcr.io/javabin/frosting:staging \
56+
ghcr.io/javabin/frosting:latest
4957
5058
- name: Generate summary
5159
run: |
5260
echo "Tag: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
61+
working-directory: frontend

.github/workflows/release.yaml

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
1-
name: Cupcake and Frosting release
1+
name: Release
22

33
on:
44
push:
55
tags:
66
- v*
77

8+
permissions:
9+
contents: read
10+
packages: write
11+
812
jobs:
913
push:
10-
name: "Build Cupcake backend - release"
1114
runs-on: ubuntu-latest
12-
13-
env:
14-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
15-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
16-
1715
steps:
18-
- name: Login to DockerHub Registry
16+
- name: Login to GHCR
1917
uses: docker/login-action@v3
2018
with:
21-
username: ${{ env.DOCKERHUB_USERNAME }}
22-
password: ${{ env.DOCKERHUB_TOKEN }}
23-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
24-
25-
- name: Get current backend
26-
run: docker pull ${{ env.DOCKERHUB_USERNAME }}/cupcake:staging
27-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
28-
29-
- name: Get current frontend
30-
run: docker pull ${{ env.DOCKERHUB_USERNAME }}/frosting:staging
31-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
32-
33-
- name: Tag release backend
34-
run: docker tag ${{ env.DOCKERHUB_USERNAME }}/cupcake:staging ${{ env.DOCKERHUB_USERNAME }}/cupcake:release
35-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
36-
37-
- name: Tag release frontend
38-
run: docker tag ${{ env.DOCKERHUB_USERNAME }}/frosting:staging ${{ env.DOCKERHUB_USERNAME }}/frosting:release
39-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
40-
41-
- name: Push release backend
42-
run: docker push ${{ env.DOCKERHUB_USERNAME }}/cupcake:release
43-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
44-
45-
- name: Push release frontend
46-
run: docker push ${{ env.DOCKERHUB_USERNAME }}/frosting:release
47-
if: ${{ env.DOCKERHUB_USERNAME != '' }}
19+
registry: ghcr.io
20+
username: ${{ github.actor }}
21+
password: ${{ github.token }}
22+
23+
- name: Create release tag from staging cupcake
24+
run: |
25+
docker buildx imagetools create \
26+
--tag ghcr.io/javabin/cupcake:release \
27+
ghcr.io/javabin/cupcake:staging
28+
29+
- name: Create version tag from staging cupcake
30+
run: |
31+
docker buildx imagetools create \
32+
--tag ghcr.io/javabin/cupcake:${{ github.ref_name }} \
33+
ghcr.io/javabin/cupcake:staging
34+
35+
- name: Create release tag from staging frosting
36+
run: |
37+
docker buildx imagetools create \
38+
--tag ghcr.io/javabin/frosting:release \
39+
ghcr.io/javabin/cupcake:staging
40+
41+
- name: Create version tag from staging frosting
42+
run: |
43+
docker buildx imagetools create \
44+
--tag ghcr.io/javabin/frosting:${{ github.ref_name }} \
45+
ghcr.io/javabin/cupcake:staging

0 commit comments

Comments
 (0)