Skip to content

Merge pull request #14 from Kusitms-Hackathon-B/ryukwankon #16

Merge pull request #14 from Kusitms-Hackathon-B/ryukwankon

Merge pull request #14 from Kusitms-Hackathon-B/ryukwankon #16

Workflow file for this run

name: Part Cross
on:
push:
branches: [ "main" ]
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: ๐Ÿƒ application.yml ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
run: |
cd ./src/main
mkdir resources
cd ./resources
touch ./application.yml
echo "$APPLICATION" > ./application.yml
mkdir firebase
cd ./firebase
echo "$FIREBASE_SDK" > ./jjikmuk-565f5-firebase-adminsdk-jh8u1-9f9aef4cad.json
env:
APPLICATION: ${{ secrets.APPLICATION }}
FIREBASE_SDK: ${{ secrets.FIREBASE_SDK }}
- name: ๐Ÿƒ gradle build๋ฅผ ์œ„ํ•œ ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•ฉ๋‹ˆ๋‹ค.
run: chmod +x gradlew
- name: ๐Ÿƒ gradle build ์ค‘์ž…๋‹ˆ๋‹ค.
run: ./gradlew build -x test
## ์ด๋ฏธ์ง€ ๋นŒ๋“œ ๋ฐ ๋„์ปคํ—ˆ๋ธŒ์— push
- name: ๐Ÿƒ docker image build ํ›„ docker hub์— pushํ•ฉ๋‹ˆ๋‹ค.
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }} .
docker push ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }}
- name: ๐Ÿƒ docker-compose.yml ํŒŒ์ผ์„ EC2 server๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.
uses: appleboy/scp-action@master
with:
username: ubuntu
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
port: ${{ secrets.EC2_PORT }}
source: "./docker-compose.yml"
target: "/home/ubuntu/"
- name: ๐Ÿƒ docker hub์—์„œ pull ํ›„ deployํ•ฉ๋‹ˆ๋‹ค.
uses: appleboy/ssh-action@master
with:
username: ubuntu
host: ${{ secrets.EC2_HOST }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
sudo docker pull ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }}
chmod 777 ./scripts/deploy.sh
cp ./scripts/deploy.sh ./deploy.sh
./deploy.sh
docker image prune -f