[BE] Fix : deleting properties #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: deploy to EC2 | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build-and-push-frontend: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: .env setting | |
run: | | |
echo "VITE_BASE_URL=${{ secrets.VITE_BASE_URL }}" >> frontend/.env | |
echo "VITE_USER1_TOKEN=${{ secrets.VITE_USER1_TOKEN }}" >> frontend/.env | |
echo "VITE_KAKAO_JAVASCRIPT_KEY=${{ secrets.VITE_KAKAO_JAVASCRIPT_KEY }}" >> frontend/.env | |
- name: Push Docker image latest | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./frontend | |
file: frontend/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ggumtle-frontend | |
build-and-push-backend: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Create application.properties | |
run: | | |
echo "${{ secrets.APP_PROPERTIES_PROD }}" >> backend/src/main/resources/application-prod.properties | |
echo "${{ secrets.APP_PROPERTIES }}" >> backend/src/main/resources/application.properties | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Push Docker image latest | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./backend | |
file: backend/Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ggumtle-backend | |
deploy-frontend: | |
needs: build-and-push-frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
sudo docker stop frontend || true | |
sudo docker rm frontend || true | |
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/ggumtle-frontend | |
sudo docker run --name frontend -d \ | |
-p 5173:5173 \ | |
--network=bridge \ | |
--restart unless-stopped \ | |
${{ secrets.DOCKERHUB_USERNAME }}/ggumtle-frontend | |
sudo docker container prune -f | |
deploy-backend: | |
needs: build-and-push-backend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
sudo docker stop backend || true | |
sudo docker rm backend || true | |
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/ggumtle-backend | |
sudo docker run --name backend -d \ | |
-p 8081:8081 \ | |
--network=bridge \ | |
--restart unless-stopped \ | |
${{ secrets.DOCKERHUB_USERNAME }}/ggumtle-backend | |
sudo docker container prune -f |