Skip to content

feat: nginx /v2 reverse-proxy setup #6

feat: nginx /v2 reverse-proxy setup

feat: nginx /v2 reverse-proxy setup #6

Workflow file for this run

name: Develop deploy workflow
on:
workflow_dispatch:
push:
branches:
- 'develop'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v3
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: ssh command deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.PEM_KEY }}
script: |
sudo docker stop spring-dev-server
sudo docker rm spring-dev-server
sudo docker rm -f $(docker ps -qa)
sudo docker image prune -a -f
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest
sudo docker run --name spring-dev-server --env-file .env -d -p 8080:8080 -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest