-
-
Notifications
You must be signed in to change notification settings - Fork 13
77 lines (75 loc) · 2.87 KB
/
workflow.yml
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
name: Galaxy Actions
on: [ push, pull_request, workflow_dispatch ]
jobs:
Build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
key: caches-${{ hashFiles('build.gradle.kts', 'gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
caches-
- name: JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Gradle
uses: gradle/wrapper-validation-action@v1
- name: Build
run: ./gradlew --no-daemon build
- name: Upload-Artifact
uses: actions/upload-artifact@v3
with:
name: jar
path: build/libs/Galaxy.jar
Docker-image:
needs: Build
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
REGISTRY_IMAGE: harbor.k8s.oktw.one/galaxy/galaxy
USERNAME: ${{ secrets.OKTW_HARBOR_USERNAME }}
PASSWORD: ${{ secrets.OKTW_HARBOR_PASSWORD }}
steps:
- name: Env
shell: bash
run: echo IMAGE_TAG=$([ "$GITHUB_REF" = "refs/heads/master" ] && echo "latest" || ([ "$GITHUB_EVENT_NAME" = 'pull_request' ] && echo pr-${{github.event.pull_request.number}} || echo ${GITHUB_REF##*/})) >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- uses: actions/download-artifact@v3
with:
name: jar
path: docker/mods/Galaxy.jar
- name: login
if: env.USERNAME != '' && env.PASSWORD != ''
uses: azure/docker-login@v1
with:
login-server: harbor.k8s.oktw.one
username: ${{ secrets.OKTW_HARBOR_USERNAME }}
password: ${{ secrets.OKTW_HARBOR_PASSWORD }}
- name: build cache
if: github.ref == 'refs/heads/master' && env.USERNAME != '' && env.PASSWORD != ''
working-directory: ./docker
run: |
docker build --build-arg BUILDKIT_INLINE_CACHE=1 --pull --cache-from $REGISTRY_IMAGE:build-cache -t $REGISTRY_IMAGE:build-cache --target builder .
docker push $REGISTRY_IMAGE:build-cache
- name: build
working-directory: ./docker
run: docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $REGISTRY_IMAGE:build-cache --cache-from $REGISTRY_IMAGE:latest -t $REGISTRY_IMAGE:$IMAGE_TAG .
- name: push
if: env.USERNAME != '' && env.PASSWORD != ''
run: docker push $REGISTRY_IMAGE:$IMAGE_TAG