๐ hotfix: ์์กด์ฑ ์ฃผ์ ๊ด๋ จ ์๋ฌ ํด๊ฒฐ #22
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: CD | |
on: # ํธ๋ฆฌ๊ฑฐ | |
push: | |
branches: [ "develop" ] | |
jobs: | |
deploy-ci: # job#1 | |
runs-on: ubuntu-22.04 | |
env: | |
working-directory: ./ # ํ๋ก์ ํธ ๋๋ ํ ๋ฆฌ | |
steps: # ์์ ๋จ์ | |
- name: ์ฒดํฌ์์ | |
uses: actions/checkout@v3 | |
- name: Java ์คํ ํ๊ฒฝ - JDK 17 ์ธํ | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: application.yml ํ์ผ ์์ฑ | |
run: | | |
# yml์ ์์ฑํ ๋๋ ํฐ๋ฆฌ๋ก ์์ ๋๋ ํฐ๋ฆฌ ์ด๋ | |
cd ./src/main/resources | |
echo "${{ secrets.APPLICATION }}" > ./application-deploy.yml | |
working-directory: ${{ env.working-directory }} | |
- name: ๋น๋ | |
run: | | |
chmod +x gradlew | |
./gradlew build | |
working-directory: ${{ env.working-directory }} | |
shell: bash | |
- name: Docker ๋น๋ ํ๊ฒฝ ์ค์ | |
uses: docker/[email protected] | |
- name: Docker Hub์ ๋ก๊ทธ์ธ | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKERHUB_LOGIN_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_LOGIN_ACCESSTOKEN }} | |
- name: Docker Image ๋น๋ ๋ฐ ํธ์ | |
run: | | |
docker build --platform linux/amd64 -t yejunpark1/motivoo-server . | |
docker push yejunpark1/motivoo-server | |
- name: deploy.sh EC2 ์ธ์คํด์ค๋ก ์ ์ก | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.RELEASE_SERVER_IP }} | |
username: ${{ secrets.RELEASE_SERVER_USER }} | |
key: ${{ secrets.RELEASE_SERVER_KEY }} | |
source: "./scripts/deploy.sh" | |
target: "/home/ubuntu/" | |
- name: docker-compose.yml EC2 ์ธ์คํด์ค๋ก ์ ์ก | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.RELEASE_SERVER_IP }} | |
username: ${{ secrets.RELEASE_SERVER_USER }} | |
key: ${{ secrets.RELEASE_SERVER_KEY }} | |
source: "./docker-compose.yml" | |
target: "/home/ubuntu/" | |
deploy-cd: # job#2 | |
needs: deploy-ci | |
runs-on: ubuntu-22.04 | |
steps: # EC2 ์ธ์คํด์ค ๋ด๋ถ์์ ์ด๋ฃจ์ด์ง๋ ์์ | |
- name: ๋์ปค ์ปจํ ์ด๋ ์คํ ๋ฐ ์ด๋ฏธ์ง Pull | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.RELEASE_SERVER_IP }} | |
username: ${{ secrets.RELEASE_SERVER_USER }} | |
key: ${{ secrets.RELEASE_SERVER_KEY }} | |
script: | | |
cd ~ | |
sudo docker pull yejunpark1/motivoo-server | |
sudo chmod 777 ./deploy.sh | |
cp ./scripts/deploy.sh ./deploy.sh | |
./deploy.sh | |
docker image prune -f |