Skip to content

Commit

Permalink
init ci
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhir committed Jul 5, 2024
1 parent 75bbdb2 commit 397bc93
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on:
pull_request:
push:
branches:
- main

jobs:
build:
uses: ./.github/workflows/maven.yaml
with:
build-images: ${{ github.ref_name == 'main' }}
release-version: dev
secrets: inherit
79 changes: 79 additions & 0 deletions .github/workflows/maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
env:
JAVA_VERSION: 17
REGISTRY: ghcr.io
TZ: Europe/Berlin

on:
workflow_call:
inputs:
snapshot-release:
description: 'Snapshot release?'
type: boolean
default: true
build-images:
description: 'Build and push images?'
type: boolean
default: false
release-version:
description: 'Release version'
type: string
required: false

jobs:
release:
runs-on: ubuntu-latest
steps:
# Checkout source code, set up Java, etc. Then...
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "temurin"
cache: "maven"
- name: Maven build
run: mvn --batch-mode clean install
- name: "Upload Artifact"
uses: actions/upload-artifact@v4
with:
name: target
path: "**/target"
retention-days: 5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-image:
if: inputs.build-images == true
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: target
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# refarch-gateway
- name: Extract metadata (tags, labels) for gateway image
id: gateway_meta
uses: docker/metadata-action@v5
with:
images: "${{ env.REGISTRY }}/${{ github.repository }}/refarch-gateway"
tags: |
type=raw,value=${{ inputs.release-version }}
type=raw,value=latest,enable=${{ inputs.snapshot-release == false }}
- name: Build and push gateway image
uses: docker/build-push-action@v4
with:
context: ./refarch-gateway
push: true
tags: ${{ steps.gateway_meta.outputs.tags }}
labels: ${{ steps.gateway_meta.outputs.labels }}
24 changes: 24 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
workflow_dispatch:
inputs:
snapshot-release:
description: 'Snapshot release?'
type: boolean
default: true
build-images:
description: 'Build and push images?'
type: boolean
default: false
release-version:
description: 'Release version'
type: string
required: false

jobs:
build:
uses: ./.github/workflows/maven.yaml
with:
snapshot-release: ${{ inputs.snapshot-release != false }}
build-images: true
release-version: ${{ inputs.release-version }}
secrets: inherit

0 comments on commit 397bc93

Please sign in to comment.