Skip to content

Commit 752842d

Browse files
committed
Separate job action for creating Docker image
- depends on build action - docker push is triggered only for branches 'master' and 'develop'
1 parent 076572b commit 752842d

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

.github/workflows/main.yml

+38-17
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ name: build
22

33
on: [push, pull_request]
44

5+
env:
6+
_JAVA_OPTIONS: "-Xms512m -Xmx4g"
7+
REPOSITORY_OWNER: ${{ github.repository }}
8+
LD_LIBRARY_PATH: "/usr/lib/lp_solve"
9+
510
jobs:
611
build:
7-
812
runs-on: ubuntu-latest
9-
1013
steps:
1114
- uses: actions/checkout@v2
1215
with:
@@ -18,16 +21,36 @@ jobs:
1821
uses: actions/setup-java@v1
1922
with:
2023
java-version: 1.8
24+
- name: Cache SBT ivy cache
25+
uses: actions/cache@v1
26+
with:
27+
path: ~/.ivy2/cache
28+
key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/build.sbt') }}
29+
- name: Cache SBT
30+
uses: actions/cache@v1
31+
with:
32+
path: ~/.sbt
33+
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
2134
- name: Install lp_solve
2235
run: sudo apt update && sudo apt install -y bash lp-solve wget zip unzip && sudo rm -rf /var/lib/apt/lists/*
2336
- name: Install lp_solve java
2437
run: (cd /tmp && wget https://sourceforge.net/projects/lpsolve/files/lpsolve/5.5.2.5/lp_solve_5.5.2.5_java.zip && unzip lp_solve_5.5.2.5_java.zip && sudo cp lp_solve_5.5_java/lib/ux64/liblpsolve55j.so /usr/lib/lp_solve && sudo ldconfig && sudo rm -rf /tmp/lp_solve_5.5_java && rm /tmp/lp_solve_5.5.2.5_java.zip)
25-
- name: Docker login
26-
uses: azure/docker-login@v1
38+
- name: Build for Scala 2.12
39+
run: sbt ++2.12.10 clean compile
40+
- name: Run Tests
41+
run: sbt ++2.12.10 test
42+
43+
docker:
44+
needs: build
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v2
2748
with:
28-
login-server: 'docker.pkg.github.com'
29-
username: ${GITHUB_ACTOR}
30-
password: ${{ secrets.GITHUB_TOKEN }}
49+
fetch-depth: 1
50+
- name: Set up JDK 1.8
51+
uses: actions/setup-java@v1
52+
with:
53+
java-version: 1.8
3154
- name: Cache SBT ivy cache
3255
uses: actions/cache@v1
3356
with:
@@ -38,16 +61,14 @@ jobs:
3861
with:
3962
path: ~/.sbt
4063
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
41-
- name: Build for Scala 2.12
42-
run: sbt ++2.12.10 clean compile
43-
- name: Run Tests
44-
run: sbt ++2.12.10 test
64+
- name: Docker login
65+
uses: azure/docker-login@v1
66+
with:
67+
login-server: 'docker.pkg.github.com'
68+
username: ${GITHUB_ACTOR}
69+
password: ${{ secrets.GITHUB_TOKEN }}
4570
- name: Create Docker Image
4671
run: sbt ++2.12.10 docker
4772
- name: Push docker images
48-
if: github.event_name != 'pull_request'
49-
run: sbt ++2.12.10 dockerPush
50-
env:
51-
_JAVA_OPTIONS: "-Xms512m -Xmx4g"
52-
REPOSITORY_OWNER: ${{ github.repository }}
53-
LD_LIBRARY_PATH: "/usr/lib/lp_solve"
73+
if: github.event_name == 'push' && (contains(github.ref, 'develop') || contains(github.ref, 'master'))
74+
run: sbt ++2.12.10 dockerPush

0 commit comments

Comments
 (0)