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 11, 2024
2 parents 94e355b + 8b9cd44 commit c263fd0
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 3 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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

- 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.GITHUB_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-render:${{ 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 }}"
- name: create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_version_name.outputs.version }}
release_name: ${{ steps.extract_version_name.outputs.version }}

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-render:${{ 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 ghcr.io/devxb/gitanimals-render:${{ steps.extract_version_name.outputs.version }}
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM arm64v8/openjdk:21

ARG DB_URL
ARG DB_USERNAME
ARG DB_PASSWORD
ARG GITHUB_TOKEN
ARG REDIS_HOST
ARG REDIS_PORT

ARG JAR_FILE=./build/libs/*.jar
COPY ${JAR_FILE} gitanimals-render.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}

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}
6 changes: 3 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
server.name=gitanimals-render
server.port=8080

spring.datasource.url=jdbc:mysql://localhost:3306/gitanimalsrender
spring.datasource.url=
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Expand All @@ -11,8 +11,8 @@ spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=false

netx.mode=redis
netx.host=localhost
netx.port=6379
netx.host=
netx.port=
netx.group=render
netx.node-id=1
netx.node-name=render-1
Expand Down

0 comments on commit c263fd0

Please sign in to comment.