Merge pull request #15 from Kusitms-Hackathon-B/jaehyeon #17
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: 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 |