-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (79 loc) · 2.64 KB
/
minimal-app.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
83
84
85
86
87
88
89
name: minimal-app-workflow
on:
pull_request:
paths:
- minimal-app/**
- .github/workflows/minimal-app.yml
push:
branches:
- main
env:
WORKING_DIR: ./minimal-app
REGISTRY: ghcr.io/octoconsulting
IMAGE_NAME: keip/minimal-app
JAVA_VERSION: 17
GIT_TAG_PREFIX: minimal-app_v
jobs:
build:
name: build image
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ${{ env.WORKING_DIR }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: "${{ env.JAVA_VERSION }}"
distribution: "temurin"
- run: mvn --batch-mode --update-snapshots verify
name: build image
release:
# TODO update to only release on main after done testing
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ${{ env.WORKING_DIR }}
permissions:
contents: write # create git tags
packages: write # push docker images
steps:
- uses: actions/checkout@v4
- run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
echo "TAG_NAME=${{ env.GIT_TAG_PREFIX }}$VERSION" >> "$GITHUB_OUTPUT"
echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$VERSION" >> "$GITHUB_OUTPUT"
cat $GITHUB_OUTPUT
id: naming-selector
name: generate names for artifacts
- run: |
! docker manifest inspect ${{ steps.naming-selector.outputs.IMAGE_NAME }}
name: confirm image is not already pushed
- run: |
git fetch --tags
! git rev-parse -q --verify "refs/tags/${{ steps.naming-selector.outputs.TAG_NAME }}"
name: confirm git tag does not exist
- uses: actions/setup-java@v3
with:
java-version: "${{ env.JAVA_VERSION }}"
distribution: "temurin"
- run: mvn --batch-mode --update-snapshots verify
name: build image
- uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker push ${{ steps.naming-selector.outputs.IMAGE_NAME }}
- uses: mathieudutour/[email protected]
id: tag_version
with:
custom_tag: ${{ steps.naming-selector.outputs.TAG_NAME }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# avoid v prefix before tag
tag_prefix: ""