-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (39 loc) · 1.34 KB
/
main.yaml
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
name: Release Containerimage
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-test-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: checkout
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build (and test) project with Maven
run: mvn -B package --file pom.xml
# set the env.BRANCH_NAME variable
- uses: nelonoel/[email protected]
- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
# set the env.COMMIT variable
- run: echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
# build the container image and release it as a package in this repository
- uses: mr-smithers-excellent/docker-build-push@v6
name: push-container-image
with:
image: mega-backend
registry: ghcr.io
dockerfile: Containerfile
buildArgs: COMMIT=${{ env.COMMIT}}, BRANCH=${{ env.BRANCH_NAME}}, VERSION=${{ env.COMMIT}}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# if the branch is main, add the latest tag
addLatest: ${{ github.ref == 'refs/heads/main' }}