-
Notifications
You must be signed in to change notification settings - Fork 233
56 lines (53 loc) · 1.59 KB
/
user-service-container-build.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
name: User Service Build and Push to GHCR
on:
push:
branches:
- main
paths:
- 'services/user-service/java/**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
REPOSITORY: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.main.outputs.version }}
created: ${{ steps.main.outputs.created }}
project: ${{ steps.main.outputs.project }}
image: ${{ steps.main.outputs.image }}
repository: ${{ steps.main.outputs.repository }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set short_sha
id: vars
run: echo "short_sha=$(git rev-parse --short HEAD)" >> ${GITHUB_ENV}
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: downcase env.REPOSITORY
run: |
echo "REPOSITORY=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'maven'
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: 3.8.2
- name: Build with Maven
run: mvn -B package --file ./services/user-service/java/pom.xml -DskipTests
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: services/user-service/java
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/user-service:${{ env.short_sha }}