chore: cd self-hosted λ³κ²½ #29
Workflow file for this run
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: Main Branch CI Pipeline | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
# λ°μ΄ν°λ² μ΄μ€ νκ²½λ³μ (RDS) | |
DB_URL: ${{ secrets.DB_URL }} | |
DB_USERNAME: ${{ secrets.DB_USERNAME }} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
## Redis νκ²½λ³μ | |
REDIS_HOST: ${{ secrets.REDIS_HOST }} | |
REDIS_PORT: ${{ secrets.REDIS_PORT }} | |
# FCM νκ²½λ³μ | |
BOTTLER_FCM_BASE64: ${{ secrets.BOTTLER_FCM_BASE64 }} | |
# AWS νκ²½λ³μ | |
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
# ECR νκ²½λ³μ | |
ECR_URI: ${{ secrets.ECR_URI }} | |
# S3 νκ²½λ³μ | |
BUCKET_NAME: ${{ secrets.BUCKET_NAME }} | |
BASE_URL: ${{ secrets.BASE_URL }} | |
# gpt νκ²½λ³μ | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
steps: | |
- name: μ½λ κ°μ Έμ€κΈ° | |
uses: actions/checkout@v4 | |
- name: JDK 17 μ€μ | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
deploy: | |
# μ°λ¦¬κ° λ±λ‘ν Github Self Hosted Runner μμ μ€νν©λλ€ | |
runs-on: self-hosted | |
# μ‘μ ꡬ체μ μΈ λ¨κ³μ λλ€ | |
steps: | |
# μ²μ _work ν΄λμ github actions νλ‘κ·Έλ¨μ΄ νμΌμ μμ ν κΆνμ΄ μμ΄μ, κΆνμ λΆμ¬ν΄ μ£ΌκΈ° μν μμ μ λλ€ | |
# μ΄ λͺ λ Ήμ ν΅ν΄μ μ΄λ―Έ μλ ν΄λμ git pull μ μ¬μ©ν μ μμ΅λλ€ | |
- name: change permission | |
# λ§μ§λ§ jwp-shopping-order λ repository μ΄λ¦μ λλ€. | |
run: | | |
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/WEB1_1_Postman_BE | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
# git clone, git pull, git fetch κ°μ μμ μ λ¨μν νκΈ° μν action μ λλ€. actions/checkout@v3 | |
# 미리 λ€λ₯Έ κ°λ°μκ° λ§λ€μ΄λ action μ μ¬μ©νλ€λ μλ―Έμ λλ€ | |
- uses: actions/checkout@v3 | |
# bootjar λ₯Ό λ§λ€κ³ , μ€νμν€λ κ³Όμ μ λ΄κ³ μμ΅λλ€ | |
- name: gradle build | |
# μ²μμ ./gradlew νμΌμ μ€νν μ μμ΄μ, chmod λ‘ μ€ν κ°λ₯νλλ‘ λ°κΏμ€λλ€ | |
run: | | |
chmod +x ./gradlew | |
./gradlew build -x test | |
# 80 λ² ν¬νΈκ° μ΄λ―Έ μλ€λ©΄, κ·Έ νλ‘κ·Έλ¨μ μ’ λ£ν©λλ€ | |
- name: kill 80 port if exist | |
run: | | |
if sudo lsof -i :80; then | |
echo "Port 80 is already in use. Killing the process..." | |
sudo lsof -i :80 | awk 'NR!=1 {print $2}' | sudo xargs kill -9 | |
fi | |
# μ€νλ§ νλ‘κ·Έλ¨μ μ€νν©λλ€ | |
- name: deploy | |
run: | | |
sudo java -jar build/libs/WEB1_1_Postman_BE.jar --spring.profiles.active=prod & |