Skip to content

๐Ÿš‘ hotfix: Spring Security ๊ด€๋ จ ์˜ค๋ฅ˜ ํ•ด๊ฒฐ #19

๐Ÿš‘ hotfix: Spring Security ๊ด€๋ จ ์˜ค๋ฅ˜ ํ•ด๊ฒฐ

๐Ÿš‘ hotfix: Spring Security ๊ด€๋ จ ์˜ค๋ฅ˜ ํ•ด๊ฒฐ #19

Workflow file for this run

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