1- # This workflow uses actions that are not certified by GitHub.
2- # They are provided by a third-party and are governed by
3- # separate terms of service, privacy policy, and support
4- # documentation.
5- # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
6- # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
7-
81name : Gradle Package
92
103on :
158 - main
169
1710jobs :
18- build :
19-
11+ build-amd64 :
2012 runs-on : ubuntu-latest
2113 permissions :
2214 contents : read
2921 with :
3022 java-version : ' 17'
3123 distribution : ' temurin'
32- server-id : github # Value of the distributionManagement/repository/id field of the pom.xml
33- settings-path : ${{ github.workspace }} # location for the settings.xml file
24+ server-id : github
25+ settings-path : ${{ github.workspace }}
26+
27+ - name : Gradle Cache
28+ uses : actions/cache@v4
29+ with :
30+ path : |
31+ ~/.gradle/caches
32+ ~/.gradle/wrapper
33+ key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
34+ restore-keys : |
35+ ${{ runner.os }}-gradle-
36+
37+ - name : Grant execute permission
38+ run : chmod +x ./gradlew
39+
40+ - name : Build with Gradle
41+ run : ./gradlew build
42+
43+ - name : Build Docker image (AMD64)
44+ run : |
45+ docker build -t ghcr.io/emotionalcore/my-app:${{ github.sha }}-amd64 .
46+
47+ - name : Log in to GitHub Container Registry (AMD64)
48+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
49+
50+ - name : Push Docker image (AMD64)
51+ run : |
52+ docker push ghcr.io/emotionalcore/my-app:${{ github.sha }}-amd64
53+
54+ build-arm64 :
55+ needs : build-amd64
56+ runs-on : [self-hosted, ARM64]
57+ permissions :
58+ contents : read
59+ packages : write
60+
61+ steps :
62+ - uses : actions/checkout@v4
63+ - name : Set up JDK 17
64+ uses : actions/setup-java@v4
65+ with :
66+ java-version : ' 17'
67+ distribution : ' temurin'
68+ server-id : github
69+ settings-path : ${{ github.workspace }}
3470
3571 - name : Gradle Cache
3672 uses : actions/cache@v4
@@ -48,23 +84,45 @@ jobs:
4884 - name : Build with Gradle
4985 run : ./gradlew build
5086
51- - name : Build Docker image # repo 이름이 소문자여야됨.
87+ - name : Build Docker image (ARM64)
5288 run : |
53- docker build -t ghcr.io/emotionalcore/my-app:${{ github.sha }} .
89+ docker build -t ghcr.io/emotionalcore/my-app:${{ github.sha }}-arm64 .
5490
91+ - name : Log in to GitHub Container Registry (ARM64)
92+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
93+
94+ - name : Push Docker image (ARM64)
95+ run : |
96+ docker push ghcr.io/emotionalcore/my-app:${{ github.sha }}-arm64
97+
98+ create-manifest-and-deploy :
99+ needs : [build-amd64, build-arm64]
100+ runs-on : ubuntu-latest
101+ permissions :
102+ contents : read
103+ packages : write
104+
105+ steps :
55106 - name : Log in to GitHub Container Registry
56107 run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
57108
58- - name : Push Docker image
109+ - name : Create Docker Manifest List
59110 run : |
60- docker tag ghcr.io/emotionalcore/my-app:${{ github.sha }} ghcr.io/emotionalcore/my-app:latest
61- docker push ghcr.io/emotionalcore/my-app:${{ github.sha }}
62- docker push ghcr.io/emotionalcore/my-app:latest
111+ docker manifest create ghcr.io/emotionalcore/my-app:latest \
112+ ghcr.io/emotionalcore/my-app:${{ github.sha }}-amd64 \
113+ ghcr.io/emotionalcore/my-app:${{ github.sha }}-arm64
114+
115+ docker manifest push ghcr.io/emotionalcore/my-app:latest
116+
117+ docker manifest create ghcr.io/emotionalcore/my-app:${{ github.sha }} \
118+ ghcr.io/emotionalcore/my-app:${{ github.sha }}-amd64 \
119+ ghcr.io/emotionalcore/my-app:${{ github.sha }}-arm64
120+ docker manifest push ghcr.io/emotionalcore/my-app:${{ github.sha }}
63121
64- - name : Deploy on Server
122+ - name : Deploy on Server
65123 uses : appleboy/ssh-action@v0.1.10
66124 with :
67125 host : ${{ secrets.SSH_HOST }}
68126 username : ${{ secrets.SSH_USER }}
69127 key : ${{ secrets.SSH_PRIVATE_KEY }}
70- script : ~/deploy.sh
128+ script : ~/deploy.sh
0 commit comments