Skip to content

Merge pull request #160 from masters2023-project-06-second-hand/dev-fe #124

Merge pull request #160 from masters2023-project-06-second-hand/dev-fe

Merge pull request #160 from masters2023-project-06-second-hand/dev-fe #124

Workflow file for this run

name: issue-tracker auto deploy
on:
push:
branches: [ "fe-release" ]
permissions:
contents: read
env:
FE_WORKING_DIR: ./fe
FE_ENV_PATH: ./.env
FE_DOCKER_FILE_PATH: ./Dockerfile
jobs:
# job[2]: FRONTEND -> docker hub로 build & push
fe-deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.FE_WORKING_DIR }}
steps:
# 1. Source 단계
- name: Checkout Source Code
uses: actions/checkout@v3
# Node 세팅
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
# 2. .env 파일 변경
- name: create .env File
run: |
echo "${{ secrets.ENV }}" > "${{ env.FE_ENV_PATH }}"
# 2. 도커파일 생성
- name: create Docker File
run: |
echo "${{ secrets.FE_DOCKER_FILE }}" > "${{ env.FE_DOCKER_FILE_PATH }}"
# 2. docker hub로 build & push
- name: docker build and push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/team-5-second-hand-fe:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/team-5-second-hand-fe:latest
# job[4]: EC2에서 docker 이미지 pull하고 실행
SSH-Transfer:
needs: [ fe-deploy ]
runs-on: ubuntu-latest
steps:
- name: SSH Transfer
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
script: |
sudo docker-compose down -v
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/team-5-second-hand-fe:latest
sudo docker-compose up -d
sudo docker image prune -a -f