-
Notifications
You must be signed in to change notification settings - Fork 2
82 lines (80 loc) · 3.28 KB
/
publish-docker-image.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: Build and publish docker image
on:
workflow_dispatch:
inputs:
push_to_registry:
type: boolean
default: false
description: Publish to registry?
environment:
type: environment
description: Select the environment
pull_request:
branches:
- 'develop'
- 'master'
- 'releases/*'
jobs:
build:
runs-on: 'ubuntu-latest'
environment: ${{ inputs.environment }}
env:
# these are global secrets - for readonly access to artifactory
INTERNAL_USERNAME: ${{ secrets.JFROG_USERNAME }}
INTERNAL_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
server-id: jfrog-central
server-username: INTERNAL_USERNAME
server-password: INTERNAL_PASSWORD
- name: Set Timestamp for docker image for development branch
if: "!(startsWith(github.ref, 'refs/heads/releases/') || startsWith(github.ref, 'refs/tags/'))"
run: echo "TIMESTAMP=-$(date +%Y.%m.%d)" >> $GITHUB_ENV
- name: Get Mobile Utility Server version
run: |
REVISION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
echo "REVISION=$REVISION" >> $GITHUB_ENV
- name: Prepare wars and libs
run: |
mvn -U -DuseInternalRepo=true --no-transfer-progress clean package
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Log in to ACR
if: vars.ACR_REGISTRY_URL != ''
uses: docker/login-action@v3
with:
registry: ${{ vars.ACR_REGISTRY_URL }}
username: ${{ vars.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Log in to Distribution registry
if: vars.DISTRIBUTION_REGISTRY_URL != ''
uses: docker/login-action@v3
with:
registry: ${{ vars.DISTRIBUTION_REGISTRY_URL }}
username: ${{ vars.DISTRIBUTION_USERNAME }}
password: ${{ secrets.DISTRIBUTION_PASSWORD }}
- name: Build and push container image to registry
uses: docker/build-push-action@v6
with:
push: ${{ inputs.push_to_registry == true }}
platforms: linux/amd64,linux/arm64
tags: |
${{ vars.ACR_REGISTRY_URL != '' && format('{0}/mobile-utility-server:{1}{2}-{3}', vars.ACR_REPOSITORY, env.REVISION, env.TIMESTAMP, github.sha) || '' }}
${{ vars.DISTRIBUTION_REGISTRY_URL != '' && format('{0}/mobile-utility-server:{1}{2}-{3}', vars.DISTRIBUTION_REPOSITORY, env.REVISION, env.TIMESTAMP, github.sha) || '' }}
file: ./deploy/dockerfile/runtime/Dockerfile
context: .
- run: echo '### 🚀 Published images' >> $GITHUB_STEP_SUMMARY
- if: inputs.push_to_registry == true && vars.ACR_REGISTRY_URL != ''
run: |
echo '${{ vars.ACR_REPOSITORY }}/mobile-utility-server:${{ env.REVISION }}${{ env.TIMESTAMP }}-${{ github.sha }}' >> $GITHUB_STEP_SUMMARY
- if: inputs.push_to_registry == true && vars.DISTRIBUTION_REGISTRY_URL != ''
run: echo '${{ vars.DISTRIBUTION_REPOSITORY }}/mobile-utility-server:${{ env.REVISION }}${{ env.TIMESTAMP }}-${{ github.sha }}' >> $GITHUB_STEP_SUMMARY