This repository was archived by the owner on Jan 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
94 lines (92 loc) · 3.24 KB
/
rest-server-release.yml
File metadata and controls
94 lines (92 loc) · 3.24 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: REST Server - Create a release
#######################################
# This creates a NubesGen REST server release:
# - An executable Jar file
# - A JVM-based Docker image
# - A native (GraalVM) Docker image
# - It deploys the native (GraalVM) Docker image to the production environment
#######################################
on:
release:
types: [published]
jobs:
build_jar:
name: Build and publish Jar file
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ${{ github.workspace }}/rest-server
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'oracle'
java-version: '23'
check-latest: false
cache: 'maven'
- name: Package the application
run: ./mvnw package
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.REPO_TOKEN }}
file: rest-server/target/*.jar
file_glob: true
tag: ${{ github.ref }}
build_docker_image_native:
name: Build and publish Docker image to GitHub Packages
runs-on: ubuntu-22.04
permissions:
packages: write
env:
DOCKER_IMAGE_NAME: 'docker.pkg.github.com/microsoft/nubesgen/nubesgen-native'
steps:
- name: Set Tag name environment variable
run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm'
java-version: '23'
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: 'maven'
- name: Build application with GraalVM
run: |
cd rest-server && ./mvnw -Pnative native:compile
- name: Login to GitHub Packages
run: docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} docker.pkg.github.com
- name: Build the native (GraalVM) Docker image
uses: docker/build-push-action@v6
with:
push: false
tags: ${{ env.DOCKER_IMAGE_NAME }}:${{ env.TAG_NAME }},${{ env.DOCKER_IMAGE_NAME }}:latest
file: ./rest-server/src/main/docker/Dockerfile.native
context: ./rest-server/
- name: Push to GitHub Packages
run: docker push ${{ env.DOCKER_IMAGE_NAME }} --all-tags
deploy:
name: Deploy to production on https://nubesgen.com
environment: prod
runs-on: ubuntu-22.04
needs: [build_docker_image_native]
env:
DOCKER_IMAGE_NAME: 'ghcr.io/microsoft/nubesgen/nubesgen-native'
steps:
- name: Set Tag name environment variable
run: echo "TAG_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Login to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Container App
uses: azure/CLI@v2
with:
inlineScript: |
az config set extension.use_dynamic_install=yes_without_prompt
az containerapp update \
-n ${{ vars.APPLICATION_NAME }} \
-g ${{ vars.RESOURCE_GROUP_NAME }} \
--image ${{ env.DOCKER_IMAGE_NAME }}:${{ env.TAG_NAME }}