Skip to content

Update prod-keyword-deploy.yml #4

Update prod-keyword-deploy.yml

Update prod-keyword-deploy.yml #4

name: ContentsService
on:
push:
branches: [ "prod-keyword" ]
pull_request:
branches: [ "prod-keyword" ]
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: Clean Gradle Cache
run: |
cd BE-Keyword-Server
ls
./gradlew clean
- name: Make application.yml
run: |
mkdir -p src/main/resources
echo "$APPLICATION" > src/main/resources/application.yml
env:
APPLICATION: ${{ secrets.APPLICATION_KEYWORD }}
- name: Grant execute permission for gradlew
run: |
cd BE-Keyword-Server
ls
chmod +x gradlew
- name: Build with Gradle
run: |
cd BE-Keyword-Server
ls
./gradlew build -x test
- name: Docker build
run: |
cd BE-Keyword-Server
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t app .
docker tag app ${{ secrets.DOCKER_USERNAME }}/keyword:latest
docker push ${{ secrets.DOCKER_USERNAME }}/keyword:latest
- name: docker-compose.yml
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.HOST_PROD_2 }}
key: ${{ secrets.PRIVATE_KEY_CONTENTS }}
port: ${{ secrets.PORT }}
source: "./BE-Keyword-Server/docker-compose-keyword.yml"
target: "/home/ec2-user/"
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_PROD_2 }}
username: ec2-user
key: ${{ secrets.PRIVATE_KEY_2 }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/keyword:latest
docker image prune -a -f
cd ./BE-Keyword-Server
docker-compose -f docker-compose-keyword.yml up -d