Merge branch 'refs/heads/main' into develop #27
Workflow file for this run
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: Build | |
on: | |
push: null | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
architecture: x64 | |
- name: Set Gradle User Home | |
run: export GRADLE_USER_HOME=$(pwd)/.gradle | |
- name: Cache Gradle Dependencies | |
uses: actions/cache@v2 | |
with: | |
path: .gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Cache Gradle Wrapper | |
uses: actions/cache@v2 | |
with: | |
path: .gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Gradle build | |
run: ./gradlew clean build --parallel | |
prepareDockerImage: | |
needs: build | |
name: Prepare docker images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
architecture: x64 | |
- name: Build Jar | |
run: ./gradlew bootJar | |
- name: Build login | |
run: docker login -u ${{ vars.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }} | |
- name: Build docker image | |
run: docker build -t iceknight07/open-chat:latest . | |
- name: Push docker image | |
run: docker push iceknight07/open-chat:latest | |
deploy: | |
needs: prepareDockerImage | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup SSH connection | |
run: | | |
eval $(ssh-agent -s) | |
mkdir -p ~/.ssh | |
chmod 700 ~/.ssh | |
ssh-keyscan ${{ vars.DEPLOY_HOST }} >> ~/.ssh/known_hosts | |
chmod 644 ~/.ssh/known_hosts | |
echo "${{ secrets.DEPLOY_KEY }}" | tr -d '\r' > ~/.ssh/private.key | |
chmod 600 ~/.ssh/private.key | |
- name: Run command | |
run: | | |
ssh -i ~/.ssh/private.key ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} \ | |
"docker stop open-chat-server || true" | |
ssh -i ~/.ssh/private.key ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} \ | |
"docker rm open-chat-server || true" | |
ssh -i ~/.ssh/private.key ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} \ | |
"docker rmi iceknight07/open-chat:latest || true" | |
ssh -i ~/.ssh/private.key ${{ vars.DEPLOY_USER }}@${{ vars.DEPLOY_HOST }} \ | |
"docker run --name open-chat-server --network=open-chat-network -p 443:8443 -d \ | |
-e POSTGRES_URL=open-chat-postgres:5432/open_chat \ | |
-e POSTGRES_USER=postgres \ | |
-e POSTGRES_PASSWORD=12345678 \ | |
-e KMS_URL=ws://kurento-media-server:8888/kurento \ | |
-e SPRING_PROFILES_ACTIVE=production \ | |
iceknight07/open-chat:latest" |