Merge remote-tracking branch 'refs/remotes/origin/frontend' into fron… #52
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: Tech-pick Client Next.js Deploy | |
on: | |
push: | |
branches: | |
- 'frontend' # Frontend 브랜치와 연결 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- # 저장소 Checkout | |
name: Checkout source code | |
uses: actions/checkout@v4 | |
- # .env 파일 설정 | |
name: Create .env.production | |
run: | | |
cd ./frontend/techpick | |
touch .env.production | |
echo "NEXT_PUBLIC_API=${{ secrets.FRONT_NEXT_PUBLIC_API }}" >> .env.production | |
echo "NEXT_PUBLIC_DOMAIN=${{ secrets.FRONT_NEXT_PUBLIC_DOMAIN }}" >> .env.production | |
echo "NEXT_PUBLIC_REDIRECT_URL=${{secrets.FRONT_NEXT_PUBLIC_REDIRECT_URL}}" >> .env.production | |
- # Docker image 빌드 | |
name: Build docker image | |
run: | | |
cd ./frontend | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/techpick:client-${{ github.sha }} . | |
- # Docker hub 로그인 | |
name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- # Docker hub 업로드 | |
name: Publish to docker hub | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/techpick:client-${{ github.sha }} | |
- # 서버 ssh 접속 후 방금 올린 이미지 pull 받고 실행 | |
name: Deploy on Test-Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: minlife.me # test home server | |
port: 4242 | |
username: root # root user | |
password: ${{ secrets.SSH_TEST_SERVER_KYEU_PASSWORD }} | |
script: | | |
echo "login docker hub for private repository access ..." | |
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
echo "docker - pulling..." | |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/techpick:client-${{ github.sha }} | |
echo "docker - changing image name and tag ..." | |
docker tag ${{ secrets.DOCKERHUB_USERNAME }}/techpick:client-${{ github.sha }} techpick:client-staging | |
cd /home/project/techpick/client | |
docker-compose down | |
docker compose up -d | |
echo "docker - pruning images that passed 24h ..." | |
docker image prune -af --filter "until=24h" | |
- # 배포 Action 실행 결과 깃허브 알림 | |
name: Discord Webhook Action | |
uses: sarisia/actions-status-discord@v1.14.7 | |
if: always() | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
status: ${{ job.status }} | |
title: 'Test Client Deployment Action Result' | |
description: '테스트 클라이언트 ${{ env.api-version }} 배포 완료' | |
color: 0xff91a4 | |
url: 'https://github.com/sarisia/actions-status-discord' | |
username: GitHub Actions |