Skip to content

Commit

Permalink
Merge pull request #1 from devxb/main
Browse files Browse the repository at this point in the history
release: 0.0.1
  • Loading branch information
devxb authored Apr 22, 2024
2 parents 97712d6 + b13eaf8 commit bd37c78
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: 🎇 Deployer

on:
push:
branches:
- 'release'

jobs:
build:
name: build and set image
runs-on: ubuntu-latest
strategy:
matrix:
kotlin-version: [ 1.9.22 ]
java-version: [ 21 ]
steps:
- name: checkout code
uses: actions/checkout@v3
with:
submodules: true

- name: Set up JDK 21 and Kotlin 1.9.22
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
kotlin-version: ${{ matrix.kotlin-version }}

- name: Cache Gradle packages
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

- name: build server
run: ./gradlew build -x test -DSENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}

- name: docker arm64 build set up - qemu
uses: docker/setup-qemu-action@v2

- name: docker arm64 build set up - buildx
uses: docker/setup-buildx-action@v2

- name: login github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- name: extract version
run: echo "##[set-output name=version;]$(echo '${{ github.event.head_commit.message }}' | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"
id: extract_version_name

- name: push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/arm64/v8
push: true
tags: |
ghcr.io/devxb/gitanimals-api:${{ steps.extract_version_name.outputs.version }}
build-args: |
"DB_URL=${{ secrets.DB_URL }}"
"DB_USERNAME=${{ secrets.DB_USERNAME }}"
"DB_PASSWORD=${{ secrets.DB_PASSWORD }}"
"GITHUB_TOKEN=${{ secrets.GH_TOKEN }}"
"REDIS_HOST=${{ secrets.REDIS_HOST }}"
"REDIS_PORT=${{ secrets.REDIS_PORT }}"
"GH_OAUTH_ID=${{ secrets.GH_OAUTH_ID }}"
"GH_OAUTH_SECRET=${{ secrets.GH_OAUTH_SECRET }}"
deploy:
needs: build
name: deploy
runs-on: self-hosted
steps:
- name: extract version
run: echo "##[set-output name=version;]$(echo '${{ github.event.head_commit.message }}' | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"
id: extract_version_name

- name: run server
run: |
sudo docker pull ghcr.io/devxb/gitanimals-api:${{ steps.extract_version_name.outputs.version }}
sudo docker ps -q --filter "expose=8080" | xargs sudo docker stop | xargs sudo docker rm
sudo docker run -d -p 8080:8080 ghcr.io/devxb/gitanimals-api:${{ steps.extract_version_name.outputs.version }}
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM arm64v8/openjdk:21

ARG DB_URL
ARG DB_USERNAME
ARG DB_PASSWORD
ARG GITHUB_TOKEN
ARG REDIS_HOST
ARG REDIS_PORT
ARG GH_OAUTH_ID
ARG GH_OAUTH_SECRET

ARG JAR_FILE=./build/libs/*.jar
COPY ${JAR_FILE} gitanimals-api.jar

ENV db_url=${DB_URL} \
db_username=${DB_USERNAME} \
db_password=${DB_PASSWORD} \
github_token=${GITHUB_TOKEN} \
redis_host=${REDIS_HOST} \
redis_port=${REDIS_PORT} \
oauth_client_id_github=${GH_OAUTH_ID} \
oauth_client_secret_github=${GH_OAUTH_SECRET}

ENTRYPOINT java -jar gitanimals-render.jar \
--spring.datasource.url=${db_url} \
--spring.datasource.username=${db_username} \
--spring.datasource.password=${db_password} \
--netx.host=${redis_host} \
--netx.port=${redis_port} \
--github.token=${github_token} \
--oauth.client.id.github=${oauth_client_id_github} \
--oauth.client.secret.github=${oauth_client_secret_github}
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
id 'org.jetbrains.kotlin.plugin.jpa' version "${jetbrainKotlinVersion}"
id "org.springframework.boot" version "${springbootVersion}"
id "io.spring.dependency-management" version "${springDependencyManagementVersion}"
id "io.sentry.jvm.gradle" version "${sentryVersion}"
}

group = "${group}"
Expand All @@ -31,3 +32,11 @@ apply from: "gradle/etc.gradle"
apply from: "gradle/test.gradle"
apply from: "gradle/spring.gradle"
apply from: "gradle/jetbrains.gradle"

sentry {
includeSourceContext = true

org = "devxb"
projectName = "gitanimals-api"
authToken = System.getProperty("SENTRY_AUTH_TOKEN")
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ snowflakeVersion=5.2.5

### Jwt ###
jwtVersion = 0.12.5

### Sentry version ###
sentryVersion = 4.4.1
3 changes: 3 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ netx.logging.level=info
github.token=
oauth.client.id.github=
oauth.client.secret.github=

sentry.dsn=https://d4fd0e848b11f200766d8cd577159b04@o4505051656486912.ingest.us.sentry.io/4507128014372864
sentry.traces-sample-rate=1.0

0 comments on commit bd37c78

Please sign in to comment.