π docs: API μλ² μ€ν λκΈ° μκ° λλ¦Ό #10
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: Motivoo Batch Server CD | |
on: # νΈλ¦¬κ±° | |
push: | |
branches: [ "develop" ] | |
paths: | |
- motivoo-api/** | |
- motivoo-domain/** | |
- motivoo-common/** | |
- motivoo-external/** | |
- .github/workflows/** | |
- ./ | |
- scripts/** | |
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: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-region: ap-northeast-2 | |
- name: application.yml (Batch λͺ¨λ) νμΌ μμ± | |
run: | | |
# ymlμ μμ±ν λλ ν°λ¦¬λ‘ μμ λλ ν°λ¦¬ μ΄λ | |
cd ./motivoo-batch/src/main/resources | |
echo "${{ secrets.APPLICATION }}" > ./application-deploy.yml | |
working-directory: ${{ env.working-directory }} | |
- name: Firebase JSON νμΌ μμ± | |
run: | | |
cd ./motivoo-batch/src/main/resources | |
mkdir ./firebase | |
cd ./firebase | |
echo $(ls -al) | |
aws s3 cp --region ap-northeast-2 s3://${{ secrets.S3_BUCKET_PATH }}/motivoo-firebase-adminsdk.json . | |
echo $(ls -al; pwd) | |
shell: bash | |
- name: Gradle Properties νμΌ μμ± | |
run: | | |
echo "${{ secrets.GRADLE_PROPERTIES }}" > ./local.properties | |
working-directory: ${{ env.working-directory }} | |
- name: λΉλ | |
run: | | |
chmod +x gradlew | |
./gradlew motivoo-batch:bootJar | |
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 -f Dockerfile-BATCH -t yejunpark1/motivoo-batch-server . | |
docker push yejunpark1/motivoo-batch-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/batch/deploy.sh" | |
target: "/home/ubuntu/batch-server/" | |
- 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-batch-server | |
sudo chmod 777 ./deploy-batch.sh | |
cp ./batch-server/scripts/batch/deploy.sh ./deploy-batch.sh | |
./deploy-batch.sh | |
docker image prune -f | |
docker-compose up -d --remove-orphans |