[Feat] news 엔티티 생성 (#10) #4
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: Java CI with Gradle | |
on: | |
push: | |
branches: [ "dev" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: make .env | |
run: | | |
touch ./.env | |
echo "${{ secrets.ENV }}" > ./.env | |
- name: SCP transfer | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.NCP_USERNAME }} | |
password: ${{ secrets.NCP_PASSWORD }} | |
port: ${{ secrets.NCP_PORT }} | |
source: ${{ secrets.SOURCE_PATH }} | |
target: ${{ secrets.DIST_PATH }} | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
- name: Docker build | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t app . | |
docker tag app ${{ secrets.DOCKER_USERNAME }}/linker:latest | |
docker push ${{ secrets.DOCKER_USERNAME }}/linker:latest | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} # NCP 서버접속용 공인 IP | |
username: ${{ secrets.NCP_USERNAME }} # instance user | |
password: ${{ secrets.NCP_PASSWORD }} # instance pw | |
port: ${{ secrets.NCP_PORT }} # port | |
script: | # docker compose deploy | |
cd /home/linker | |
docker-compose -f docker-compose.dev.yml down | |
docker pull ${{ secrets.DOCKER_USERNAME }}/linker:latest | |
docker-compose -f docker-compose.dev.yml up --build -d | |
docker rm $(docker ps --filter 'status=exited' -a -q) | |
docker image prune -a -f |