release: 1.1.9 (#246) #135
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: move jar file to deploy api | |
run: mv ./build/libs/*.jar ./deploy/api/ | |
- 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: build and push api server | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./deploy/api | |
platforms: linux/arm64/v8 | |
push: true | |
tags: | | |
ghcr.io/devxb/gitanimals:${{ 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 }}" | |
"INTERNAL_SECRET=${{ secrets.INTERNAL_SECRET }}" | |
"SLACK_TOKEN=${{ secrets.SLACK_TOKEN }}" | |
- name: build and push filebeat | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./deploy/filebeat | |
platforms: linux/arm64/v8 | |
push: true | |
tags: | | |
filebeat-gitanimals:latest | |
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 api server | |
run: | | |
sudo docker pull ghcr.io/devxb/gitanimals:${{ 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 8081:8080 -v logs:/logs ghcr.io/devxb/gitanimals:${{ steps.extract_version_name.outputs.version }} | |
- name: check filebeat status | |
id: check-status | |
run: | | |
if docker ps --filter "name=filebeat" --filter "status=running" --format "{{.Names}}" | grep -q "^filebeat$"; then | |
echo "Filebeat is already running" | |
echo "status=running" >> $GITHUB_ENV | |
else | |
echo "Filebeat is not running" | |
echo "status=stopped" >> $GITHUB_ENV | |
fi | |
- name: display filebeat status | |
run: | | |
if [ "${{ env.status }}" == "running" ]; then | |
echo "β Filebeat is already running" | |
else | |
echo "π Filebeat is not running. Starting deployment..." | |
fi | |
- name: run file beats | |
if: env.status == 'stopped' | |
run: | | |
sudo docker run -d --name filebeat -v logs:/logs -t filebeat-gitanimals:latest | |