Skip to content

Commit

Permalink
[BE] ✨ : github action 기능 추가 (#115)
Browse files Browse the repository at this point in the history
* swagger 설정

* ✨ github action 추가

* 이름 수정
  • Loading branch information
twoo1999 authored Nov 25, 2023
1 parent e161df4 commit 87a77fd
Showing 1 changed file with 36 additions and 46 deletions.
82 changes: 36 additions & 46 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
# name: musicspot github actions

# on:
# pull_request:
# branches: ["BE/release"]
# types: ["closed"]
# jobs:
# deploy:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# - name: Set up Node.js
# uses: actions/setup-node@v2
# with:
# node-version: "20"

# - name: Install dependencies
# run: |
# cd BE
# cd musicspot
# npm install

# - name: Build Docker image
# run: docker build -t musicspot:latest ./BE/musicspot

# - name: Login to Docker Hub
# run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}

# - name: Push Docker image to Docker Hub
# run: docker push musicspot

# - name: SSH into Ubuntu server and pull the latest image
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SERVER_IP }}
# username: ${{ secrets.SERVER_USERNAME }}
# password: ${{ secrets.PASSWORD }}
# script: |
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# docker pull musicspot
# docker stop musicspot || true
# docker rm musicspot || true
# docker run -e SSH_HOST=${{ secrets.SSH_HOST }} -e SSH_PORT=${{ secrets.SSH_PORT }} -e SSH_USER=${{ secrets.SSH_USER }} -e SSH_PASSWORD=${{ secrets.SSH_PASSWORD }} -e DB_USERNAME=${{ secrets.DB_USERNAME }} -e DB_PASSWORD=${{ secrets.DB_PASSWORD }} -e DB_NAME=${{ secrets.DB_NAME }} -e DB_HOST=${{ secrets.DB_HOST }} -e SECRET_KEY=${{ secrets.SECRET_KEY }} -v /images:/images -v /images/profile:/images/profile -v /images/story:/images/story -d -p 3000:3000 --name heatpick-container geomgichoi/heatpick
name: Music Spot Project

on:
push:
branches: ["BE/release"]
pull_request:
branches: ["BE/release"]
types: [closed]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: |
docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_TOKEN}}
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:${{github.sha}} ./
docker images
docker push ${{secrets.DOCKER_USERNAME}}/${{secrets.DOCKER_REPO}}:${{github.sha}}
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SERVER_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
cd compose
sudo docker rm -f $(sudo docker ps -qa)
sudo docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:${{github.sha}}
sudo docker tag ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:${{github.sha}} ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO}}:latest
sudo docker compose up -d
sudo docker image prune -af

0 comments on commit 87a77fd

Please sign in to comment.