Skip to content

Commit

Permalink
add the new build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeindl committed Apr 30, 2024
1 parent 146363d commit 3586d81
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Release Containerimage

on:
push:
branches:
- main
workflow_dispatch:

jobs:
Expand All @@ -10,47 +13,34 @@ jobs:
- uses: actions/checkout@v3
name: checkout

- name: Cache the Maven packages to speed up build
uses: actions/cache@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build and test project with Maven
run: mvn -B package -D skipTests --file pom.xml
- name: Build (and test) project with Maven
run: mvn -B package --file pom.xml

# set the env.BRANCH_NAME variable
- uses: nelonoel/branch-name@v1.0.1

- name: Set outputs
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- uses: mr-smithers-excellent/docker-build-push@v5
# 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
username: ${{ github.repository }}
password: ${{ secrets.GHCR_TOKEN }}
dockerfile: Containerfile
addLatest: true
tags: ${{ steps.vars.outputs.sha_short }},latest
buildArgs: BRANCH=${BRANCH_NAME},COMMIT=${{ steps.vars.outputs.sha_short }},VERSION=${{ steps.vars.outputs.sha_short }}

# notify:
# name: Slack Notifications
# runs-on: ubuntu-latest
# if: ${{ failure() }}
# needs:
# - build-and-test
# - docker-build-and-push
# steps:
# - name: Notify Slack channel on failure
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_ICON: https://avatars.githubusercontent.com/u/74975412?s=200&v=4
# SLACK_USERNAME: ${{ github.repository }}
# SLACK_COLOR: '#ff0033'
# SLACK_FOOTER: ''
buildArgs: COMMIT=${{ env.COMMIT}}, BRANCH=${{ env.BRANCH_NAME}}, VERSION=${{ env.COMMIT}}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
addLatest: ${{ github.ref == 'refs/heads/main' }}

0 comments on commit 3586d81

Please sign in to comment.