Skip to content

Feat : 캐릭터최초설정(회원가입) #62

Feat : 캐릭터최초설정(회원가입)

Feat : 캐릭터최초설정(회원가입) #62

Workflow file for this run

name: Java CI/CD with Gradle
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
types: [ closed ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
env:
PROFILE: prod
PROD_DB_HOST: ${{ secrets.PROD_DB_HOST }}
PROD_DB_USERNAME: ${{ secrets.PROD_DB_USERNAME }}
PROD_DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }}
SOCIAL_CLIENT_ID: ${{ secrets.SOCIAL_CLIENT_ID }}
SOCIAL_CLIENT_PASSWD: ${{ secrets.SOCIAL_CLIENT_PASSWD }}
SOCIAL_CLIENT_SECRET: ${{ secrets.SOCIAL_CLIENT_SECRET }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle
run: ./gradlew --warning-mode all build -i
docker-build:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permisson for gradlew
run: chmod +x gradlew
- name: Build with Gradle (without Test)
run: ./gradlew clean build -x test --stacktrace
- name: Docker Hub build & push
run: |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PWD }}
docker build --build-arg PROFILE=${{ secrets.PROFILE }} \
--build-arg DB_PROD_USERNAME=${{ secrets.DB_PROD_USERNAME }} \
--build-arg DB_PROD_USERNAME=${{ secrets.DB_PROD_USERNAME }} \
--build-arg DB_PROD_PASSWD=${{ secrets.DB_PROD_PASSWD }} \
--build-arg SOCIAL_CLIENT_ID=${{ secrets.SOCIAL_CLIENT_ID }} \
--build-arg SOCIAL_CLIENT_PASSWD=${{ secrets.SOCIAL_CLIENT_PASSWD }} \
--build-arg SOCIAL_CLIENT_SECRET=${{ secrets.SOCIAL_CLIENT_SECRET }} \
--build-arg JWT_SECRET=${{ secrets.JWT_SECRET }} \
-t linkode/linkode:latest .
docker images
docker push linkode/linkode:latest
- name: deploy
uses: appleboy/ssh-action@master
with:
username: ubuntu
host: ${{ secrets.WAS_HOST }}
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.WAS_PORT }}
script: |
CONTAINER_ID=$(sudo docker ps -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }})
if [ ! -z "$CONTAINER_ID" ]; then
sudo docker stop $CONTAINER_ID
sudo docker rm $CONTAINER_ID
fi
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
sudo docker run -d -e PROFILE=${{ secrets.PROFILE }} \
-e DB_PROD_HOST=${{ secrets.DB_PROD_HOST }} \
-e DB_PROD_USERNAME=${{ secrets.DB_PROD_USERNAME }} \
-e DB_PROD_PASSWD=${{ secrets.DB_PROD_PASSWD }} \
-e SOCIAL_CLIENT_ID=${{ secrets.SOCIAL_CLIENT_ID }} \
-e SOCIAL_CLIENT_PASSWD=${{ secrets.SOCIAL_CLIENT_PASSWD }} \
-e SOCIAL_CLIENT_SECRET=${{ secrets.SOCIAL_CLIENT_SECRET }} \
-e JWT_SECRET=${{ secrets.JWT_SECRET }}
-p 8080:8080 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
sudo docker logs $(sudo docker ps -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }})
sudo docker image prune -f