-
Notifications
You must be signed in to change notification settings - Fork 34
82 lines (65 loc) · 2.21 KB
/
docker-publish.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
78
79
80
81
82
name: Docker
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
label:
types: [created]
env:
IMAGE_NAME: mars-sim
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Build with Maven
run: mvn -B package -DskipTests=true --file pom.xml
- name: Copy Jar file
run: |
# Find the project version off the MVN pom
MARS_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
mv mars-sim-headless/target/mars-sim_console_$MARS_VERSION.jar mars-sim-console.jar
- uses: actions/upload-artifact@master
with:
name: jar-file
path: mars-sim-console.jar
build-image:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@master
with:
name: jar-file
path: mars-sim-console.jar
- name: Build image with Package Docker
run: |
# Build the image
docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Find the project version off the MVN pom
MARS_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$MARS_VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$MARS_VERSION
docker push $IMAGE_ID:$MARS_VERSION