-
-
Notifications
You must be signed in to change notification settings - Fork 135
129 lines (110 loc) · 3.89 KB
/
Copy pathpublish-docker.yml
File metadata and controls
129 lines (110 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Publish images via Docker
on:
release:
types: [ published ]
env:
APP_NAME: datacap
GITHUB_REGISTRY: ghcr.io
APP_GITHUB_GROUP: devlive-community
APP_DOCKER_GROUP: devliveorg
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
jobs:
before-compile:
runs-on: ubuntu-latest
outputs:
APP_VERSION: ${{ steps.apply_version.outputs.APP_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup java
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Generate app version
run: echo APP_VERSION=`./mvnw -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.help=INFO | tail -1` >> "$GITHUB_OUTPUT"
id: apply_version
- name: Compile from source
run: |
chmod 755 ./mvnw
./mvnw clean install package -Dspotbugs.skip -Dgpg.skip -Dcheckstyle.skip -DskipTests=true -q
- name: Cache binary
id: cache-binary
uses: actions/cache@v3
env:
cache-name: cache-binary
with:
path: |
./Dockerfile
./dist/datacap-server-${{ steps.apply_version.outputs.APP_VERSION }}-bin.tar.gz
key: ${{ runner.os }}-build-${{ env.cache-name }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
publish-github-ghcr:
runs-on: ubuntu-latest
needs:
- before-compile
steps:
- name: Get cache binary
id: cache-binary
uses: actions/cache@v3
env:
cache-name: cache-binary
with:
path: |
./Dockerfile
./dist/datacap-server-${{ needs.before-compile.outputs.APP_VERSION }}-bin.tar.gz
key: ${{ runner.os }}-build-${{ env.cache-name }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login
uses: docker/login-action@v2
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: qianmoq
password: ${{ secrets.PACKAGES_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: |
${{ env.GITHUB_REGISTRY }}/${{ env.APP_GITHUB_GROUP }}/${{ env.APP_NAME }}:${{ needs.before-compile.outputs.APP_VERSION }}
${{ env.GITHUB_REGISTRY }}/${{ env.APP_GITHUB_GROUP }}/${{ env.APP_NAME }}:latest
publish-docker-hub:
runs-on: ubuntu-latest
needs:
- before-compile
steps:
- name: Get cache binary
id: cache-binary
uses: actions/cache@v3
env:
cache-name: cache-binary
with:
path: |
./Dockerfile
./dist/datacap-server-${{ needs.before-compile.outputs.APP_VERSION }}-bin.tar.gz
key: ${{ runner.os }}-build-${{ env.cache-name }}
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: |
${{ env.APP_DOCKER_GROUP }}/${{ env.APP_NAME }}:${{ needs.before-compile.outputs.APP_VERSION }}
${{ env.APP_DOCKER_GROUP }}/${{ env.APP_NAME }}:latest