Merge pull request #233 from boostcampwm-2024/nks-test #14
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: Build and Deploy to NCP | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: clovapatra-container-registry.kr.ncr.ntruss.com | |
FE_IMAGE: clovapatra-container-registry.kr.ncr.ntruss.com/clovapatra-fe | |
GAME_IMAGE: clovapatra-container-registry.kr.ncr.ntruss.com/clovapatra-game | |
SIGNALING_IMAGE: clovapatra-container-registry.kr.ncr.ntruss.com/clovapatra-signaling | |
VOICE_IMAGE: clovapatra-container-registry.kr.ncr.ntruss.com/clovapatra-voice | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Copy Dockerfiles to root directory | |
- name: Copy Dockerfiles to root | |
run: | | |
echo "${{ secrets.FE_ENV }}" > ./fe/.env | |
echo "${{ secrets.ENV_GAME }}" > ./be/gameServer/.env | |
echo "${{ secrets.ENV_SIGNALING }}" > ./be/signalingServer/.env | |
echo "${{ secrets.ENV_VOICE }}" > ./be/voiceProcessingServer/.env | |
cp .nks/fe_Dockerfile ./Dockerfile.fe | |
cp .nks/game_Dockerfile ./Dockerfile.game | |
cp .nks/signaling_Dockerfile ./Dockerfile.signaling | |
cp .nks/voice_Dockerfile ./Dockerfile.voice | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to NCP Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.NCP_ACCESS_KEY }} | |
password: ${{ secrets.NCP_SECRET_KEY }} | |
# Build and push Frontend | |
- name: Build and push frontend image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile.fe | |
push: true | |
tags: ${{ env.FE_IMAGE }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Build and push Game Server | |
- name: Build and push game server image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile.game | |
push: true | |
tags: ${{ env.GAME_IMAGE }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Build and push Signaling Server | |
- name: Build and push signaling server image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile.signaling | |
push: true | |
tags: ${{ env.SIGNALING_IMAGE }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Build and push Voice Processing Server | |
- name: Build and push voice processing server image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile.voice | |
push: true | |
tags: ${{ env.VOICE_IMAGE }}:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Push to NCP Source Commit | |
- name: Set up Git Config | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
- name: Add NCP Remote | |
run: | | |
git remote add ncp https://${{ secrets.NCP_USERNAME }}:${{ secrets.NCP_PASSWORD_URL_ENCODED }}@${{ secrets.NCP_REPO_URL }} | |
- name: Push to NCP Main Branch | |
run: | | |
git push ncp main --force |