Merge pull request #50 from jjikky/refactor/prod-deploy #21
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: SIGNALING SERVER DEV CD | |
on: | |
push: | |
branches: [dev] | |
jobs: | |
docker-build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 리포지토리 체크아웃 | |
uses: actions/checkout@v3 | |
- name: env 생성 | |
run: | | |
echo "# SERVER" > .env | |
echo "PORT=${{ secrets.PORT }}" >> .env | |
echo "NODE_ENV=development" >> .env | |
echo "SERVER_PATH=${{ secrets.SERVER_PATH }}" >> .env | |
echo "CORS_WHITELIST={{secrets.CORS_WHITELIST}}" >> .env | |
echo "# RTC" >> .env | |
echo "MAXIMUM_CONNECTION=${{ secrets.MAXIMUM_CONNECTION }}" >> .env | |
echo "# SPRING" >> .env | |
echo "SPRING_SERVER_URL_DEV=${{ secrets.SPRING_SERVER_URL_DEV }}" >> .env | |
echo "# REDIS" >> .env | |
echo "REDIS_HOST_DEV=${{ secrets.REDIS_HOST_DEV }}" >> .env | |
echo "REDIS_PORT=${{ secrets.REDIS_PORT }}" >> .env | |
- name: Docker Hub 로그인 | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Docker 이미지 빌드 | |
run: docker build -t dao-signaling-server:dev . | |
- name: Docker 이미지 Tagging | |
run: docker tag dao-signaling-server:dev jjikky/dao-signaling-server:dev | |
- name: Docker Hub에 이미지 푸시 | |
run: docker push jjikky/dao-signaling-server:dev | |
docker-pull-and-run: | |
runs-on: dev-signaling-runner | |
needs: [docker-build-and-push] | |
if: ${{ needs.docker-build-and-push.result == 'success' }} | |
steps: | |
- name: Docker Hub에서 Docker 이미지를 pull | |
run: | | |
sudo docker login --username ${{ secrets.DOCKER_USERNAME }} --password ${{ secrets.DOCKER_PASSWORD }} | |
sudo docker pull jjikky/dao-signaling-server:dev | |
- name: Docker 컨테이너 시작 | |
run: | | |
sudo chmod +x deploy.sh | |
sudo ./deploy.sh | |
- name: 도커 이미지 정리 | |
run: | | |
sudo docker image prune --all --force |