Skip to content

Commit

Permalink
Update workflow and add new workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
a-m-zill committed May 10, 2023
1 parent abbdbd1 commit 84555e1
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 4 deletions.
32 changes: 28 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
name: build and test
name: compliance check and build test

on: [push]

jobs:
compliance:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Advance Security Policy as Code
uses: advanced-security/policy-as-code@v2.0
uses: advanced-security/policy-as-code@v2.1.2
with:
policy: GeekMasher/security-queries
policy-path: policies/default.yml

token: ${{ secrets.ACCESS_TOKEN }}

argvs: '--disable-dependabot --disable-secret-scanning --disable-code-scanning'

build-maven:
needs: compliance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "temurin"
cache: "maven"

- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Build with Maven
run: mvn -B verify "-Dspring-boot.run.jvmArguments=-Dfile.encoding=UTF-8" -DskipTests=true
46 changes: 46 additions & 0 deletions .github/workflows/build_feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build feature branch

on: [workflow_dispatch]

jobs:
build-and-docker-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "temurin"
cache: "maven"

- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Build with Maven
run: mvn -B verify "-Dspring-boot.run.jvmArguments=-Dfile.encoding=UTF-8" -DskipTests=true

- uses: gacts/github-slug@v1
id: slug

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_KEY }}

- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: itatm/dave-admin-portal:${{ steps.slug.outputs.branch-name-slug }}
111 changes: 111 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: release

# Run workflow on commits to the `main` branch
on:
pull_request:
types:
- closed
branches:
- 'main'

jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SECRET_KEY }}

- name: Install Java and Maven
uses: actions/setup-java@v3
with:
java-version: 11
distribution: "temurin"
cache: "maven"
- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16
- name: Clean Maven Project Version
id: set-version
run: |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Current version: $current_version"
new_version=$(echo $current_version | sed 's/-SNAPSHOT//')
echo "New version: $new_version"
mvn -B versions:set -DnewVersion=$new_version
mvn -B versions:set -DnewVersion=$new_version -DprocessAllModules
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
git add pom.xml
git add **/pom.xml
git commit -m "Bump main version to $new_version"
git push
echo "::set-output name=new_version::$new_version"
- name: Build with Maven
run: mvn -B verify "-Dspring-boot.run.jvmArguments=-Dfile.encoding=UTF-8" -DskipTests=true

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_KEY }}

- name: Build and push app
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: itatm/dave-admin-portal:${{ steps.set-version.outputs.new_version }},itatm/dave-admin-portal:latest

- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_KEY }}
repository: itatm/dave-admin-portal
short-description: Über das Adminportal können Zählstellen angelegt und bearbeitet werden.

# github-release:
# needs: if_merged
# name: Create Release
# # if: github.event.inputs.snapshot-build == 'n'
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3

# - name: Create tag
# uses: actions/github-script@v6
# with:
# script: |
# github.rest.git.createRef({
# owner: context.repo.owner,
# repo: context.repo.repo,
# ref: 'refs/tags/${{ github.event.inputs.release-tag }}',
# sha: context.sha
# })
# - name: Create GitHub Release
# id: create_release
# uses: softprops/action-gh-release@v1
# with:
# tag_name: ${{ github.event.inputs.release-tag }}
# draft: false
# prerelease: false
# generate_release_notes: true
# - name: Update Docker Hub Description
# uses: peter-evans/dockerhub-description@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_KEY }}
# repository: itatm/dave-frontend
# readme-filepath: ./IMAGE_README.md
# short-description: ${{ github.event.repository.description }}
88 changes: 88 additions & 0 deletions .github/workflows/snapshot_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build snapshot container

on:
workflow_dispatch:
inputs:
version:
description: 'Which part of the version to increase (major, minor, patch)'
required: false
default: 'none'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.SECRET_KEY }}

- name: Set Maven Project Version
id: set-version
run: |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Current version: $current_version"
if [ "${{ github.event.inputs.version }}" == "none" ]; then
new_version="$current_version"
elif [ "${{ github.event.inputs.version }}" == "major" ]; then
new_version=$(echo $current_version | awk -F. -v OFS=. '{$1=$1+1; $2=0; $3=0; print $0"-SNAPSHOT"}')
elif [ "${{ github.event.inputs.version }}" == "minor" ]; then
new_version=$(echo $current_version | awk -F. -v OFS=. '{$2=$2+1; $3=0; print $0"-SNAPSHOT"}')
else
new_version=$(echo $current_version | awk -F. -v OFS=. '{$3=$3+1; print $0"-SNAPSHOT"}')
fi
echo "New version: $new_version"
mvn -B versions:set -DnewVersion=$new_version
mvn -B versions:set -DnewVersion=$new_version -DprocessAllModules
if [ "${{ github.event.inputs.version }}" != "none" ]; then
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
git add pom.xml
git add **/pom.xml
git commit -m "Bump version to $new_version"
git push
fi
echo "::set-output name=new_version::$new_version"
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "temurin"
cache: "maven"

- name: Set up Node 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Build with Maven
run: mvn -B verify "-Dspring-boot.run.jvmArguments=-Dfile.encoding=UTF-8" -DskipTests=true

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_KEY }}

- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: itatm/dave-admin-portal:${{ steps.set-version.outputs.new_version }}

- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_KEY }}
repository: itatm/dave-admin-portal
short-description: Über das Adminportal können Zählstellen angelegt und bearbeitet werden.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM registry.access.redhat.com/ubi8/openjdk-11:latest

COPY apigateway/target/*.jar /deployments/spring-boot-application.jar

0 comments on commit 84555e1

Please sign in to comment.