[FIX] 파일 못찾는 문제 해결 (#52) #44
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: Build and Deploy | |
on: | |
push: | |
branches: [ develop ] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'corretto' | |
- name: Create application.properties | |
run: | | |
echo "${{ secrets.FIREBASE }}" > src/main/resources/firebase.json | |
echo "${{ secrets.APPLICATION_TEST }}" > src/main/resources/application-test.properties | |
echo "${{ secrets.APPLICATION_LOCAL }}" > src/main/resources/application-local.properties | |
echo "${{ secrets.APPLICATION_DEV }}" > src/main/resources/application-dev.properties | |
- name: Build with Maven | |
run: mvn -e clean package -DskipTests | |
- name: Docker build and push | |
run: | | |
sudo docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }} . | |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
sudo docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }} | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
# Stop and remove the existing container | |
sudo docker stop ${{ secrets.DOCKER_CONTAINER_NAME }} | |
sudo docker rm ${{ secrets.DOCKER_CONTAINER_NAME }} | |
# Remove the existing image | |
sudo docker rmi ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }} | |
# Login | |
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
# Pull and run the application container | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_CONTAINER_NAME }} | |
sudo docker run -d -p 8080:8080 --name ${{ secrets.DOCKER_CONTAINER_NAME }} ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }} |