1- name : Cupcake Backend
1+ name : Build Cupcake
22
33on :
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
918jobs :
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/
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-
0 commit comments