Merge pull request #73 from Repick-official/develop #262
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 Production Server | |
on: | |
push: | |
branches: [ "prod" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
## gradle build | |
- name: Build with Gradle | |
run: ./gradlew bootJar | |
## μΉ μ΄λ―Έμ§ λΉλ λ° λ컀νλΈμ push | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_REPO }}/repick-web . | |
docker push ${{ secrets.DOCKER_REPO }}/repick-web | |
docker build -f dockerfile-nginx -t ${{ secrets.DOCKER_REPO }}/repick-nginx . | |
docker push ${{ secrets.DOCKER_REPO }}/repick-nginx | |
## docker compose up | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
cd /home/ubuntu/repick/ | |
sudo touch .env | |
echo "${{ secrets.ENV_VARS }}" | sudo tee .env > /dev/null | |
sudo touch docker-compose.yaml | |
echo "${{ vars.DOCKER_COMPOSE }}" | sudo tee docker-compose.yaml > /dev/null | |
sudo chmod 666 /var/run/docker.sock | |
sudo docker rm -f $(docker ps -qa) | |
sudo docker pull ${{ secrets.DOCKER_REPO }}/repick-web | |
sudo docker pull ${{ secrets.DOCKER_REPO }}/repick-nginx | |
docker-compose -f docker-compose.yaml --env-file /home/ubuntu/repick/.env up -d | |
docker image prune -f |