diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..552245d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: deploy-actions + +on: + push: + branches: [prod] + +jobs: + ci: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GIT_TOKEN }} + submodules: true + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and Push Docker images + run: | + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }} . + docker push {{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:latest + + + cd: + needs: [ci] + runs-on: ubuntu-20.04 + + steps: + - name: Docker Image Pull And Container Run + uses: appleboy/ssh-action@v1.0.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + port: ${{ secrets.PORT }} + script: | + docker compose down + docker system prune -a + docker compose pull + docker compose up -d \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 28b53ff..ff4253d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ -spring.profiles.default: local +spring.profiles.default: prod ---