Merge pull request #222 from Meetfolio-Project-CodeZ-Team/develop #163
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 Next.js with Docker | |
on: | |
push: | |
branches: ['main'] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Docker Login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Docker build and Push | |
run: | | |
docker build \ | |
--build-arg NEXT_PUBLIC_SERVER=${{ secrets.NEXT_PUBLIC_SERVER }} \ | |
--build-arg NEXT_PUBLIC_NEXT_SERVER=${{ secrets.NEXT_PUBLIC_NEXT_SERVER }} \ | |
--build-arg NEXT_PUBLIC_GAHCON_SERVER=${{ secrets.NEXT_PUBLIC_GAHCON_SERVER }} \ | |
-t ${{ secrets.DOCKER_USERNAME }}/meetfolio-web:latest . | |
docker push ${{secrets.DOCKER_USERNAME}}/meetfolio-web:latest | |
- name: Deploy in GCP | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.GCE_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/meetfolio-web:latest | |
sudo docker tag ${{ secrets.DOCKER_USERNAME }}/meetfolio-web:latest meetfolio-web:latest | |
sudo docker rm -f meetfolio-web | |
sudo docker run -d --name meetfolio-web -e TZ=Asia/Seoul -e PORT=60005 -p 60005:60005 meetfolio-web:latest | |
sudo docker image prune -af |