Skip to content

Deploy JVM Image

Deploy JVM Image #23

Workflow file for this run

name: Deploy JVM Image
env:
REGISTRY: ghcr.io
JAVA_VERSION: '21'
JAVA_DISTRIBUTION: 'temurin'
IMAGE_NAME: ${{ github.repository }}
# Configuration for deployment targets
# Services listed here will be deployed to Kubernetes
K8S_SERVICES: 'data-api chainlayer'
on:
workflow_dispatch:
inputs:
application_to_deploy:
type: choice
options: ['data-ingestion', 'data-api', 'chainlayer']
description: 'What to restart'
required: true
default: 'data-ingestion'
jobs:
deploy:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRIBUTION }}
cache: 'maven'
- name: Maven Build and Cache
uses: actions/cache@v3
id: maven-cache
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ hashFiles('**/src/**/*.kt') }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B package -DskipTests=true --no-transfer-progress
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ github.event.inputs.application_to_deploy }}
tags: |
type=sha,format=long
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ${{ github.event.inputs.application_to_deploy }}/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Set up kubectl
if: contains(env.K8S_SERVICES, github.event.inputs.application_to_deploy)
uses: azure/setup-kubectl@v3
with:
version: 'latest'
- name: Kubernetes context
if: contains(env.K8S_SERVICES, github.event.inputs.application_to_deploy)
uses: Azure/k8s-set-context@v1
with:
method: kubeconfig
kubeconfig: ${{ secrets.K8S_CONFIG }}
- name: Restart deployment
if: contains(env.K8S_SERVICES, github.event.inputs.application_to_deploy)
run: |
kubectl rollout restart deployment/${{ github.event.inputs.application_to_deploy }} -n decentrifi
- name: Package-only deployment notice
if: "!contains(env.K8S_SERVICES, github.event.inputs.application_to_deploy)"
run: |
echo "::notice::${{ github.event.inputs.application_to_deploy }} was only deployed to package registry. No Kubernetes deployment performed."