forked from AuScope/AuScope-Portal-API
-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (63 loc) · 2.25 KB
/
build-prod-release.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
# Create a Docker build for a production release
name: build-prod-release
on:
# Manually triggered, user must supply tag
workflow_dispatch:
inputs:
api-buildtag:
description: 'AuScope-Portal-API build tag: (format: vX.Y.Z)'
required: true
pc-buildtag:
description: 'portal-core build tag: (format: vX.Y.Z)'
required: true
env:
IMAGE_NAME: auscope-portal-api-prod-release
jobs:
# Push image to GitHub Packages.
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.api-buildtag }}
- name: Set up JDK 1.17
uses: actions/setup-java@v1
with:
java-version: 1.17
- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Checkout portal-core
uses: actions/[email protected]
with:
repository: AuScope/portal-core
ref: ${{ github.event.inputs.pc-buildtag }}
path: portal-core
- name: Build portal-core
run: |
cd portal-core
mvn clean install
- name: Build with Maven, then with docker
run: |
mvn -B package --file pom.xml
ls -lR target
WAR_VERSION=$(echo "${{ github.event.inputs.api-buildtag }}" | sed 's/v//')
echo WAR_VERSION=$WAR_VERSION
docker build . --file Dockerfile.github --tag $IMAGE_NAME --build-arg war_file=target/auscope-portal-api-$WAR_VERSION.war
- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Always the latest version
VERSION=latest
echo "Build Tag: ${{ github.event.inputs.buildtag }}"
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION