diff --git a/.github/workflows/github-actions-dev.yaml b/.github/workflows/github-actions-dev.yaml index ee13ecf..b7933a3 100644 --- a/.github/workflows/github-actions-dev.yaml +++ b/.github/workflows/github-actions-dev.yaml @@ -33,8 +33,9 @@ jobs: NEXT_PUBLIC_SERVER_URL: ${{ secrets.NEXT_PUBLIC_SERVER_URL_DEV }} NEXT_PUBLIC_SELF_URL: ${{ secrets.NEXT_PUBLIC_SELF_URL_DEV }} NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL_DEV }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN_DEV }} + NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN_DEV }} + NEXT_PUBLIC_KAKAOJSKEY: ${{ secrets.NEXT_PUBLIC_KAKAOJSKEY_DEV }} - name: Log in to GitHub Container Registry uses: docker/login-action@v3 @@ -51,30 +52,26 @@ jobs: --build-arg NEXT_PUBLIC_SERVER_URL=${{ secrets.NEXT_PUBLIC_SERVER_URL_DEV }} \ --build-arg NEXT_PUBLIC_SELF_URL=${{ secrets.NEXT_PUBLIC_SELF_URL_DEV }} \ --build-arg NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL_DEV }} \ - --build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \ - --build-arg NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN }} \ + --build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN_DEV }} \ + --build-arg NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN_DEV }} \ + --build-arg NEXT_PUBLIC_KAKAOJSKEY=${{ secrets.NEXT_PUBLIC_KAKAOJSKEY_DEV }} \ -t ghcr.io/topazkang/fe-dev:latest . - name: Push Docker image to GHCR run: docker push ghcr.io/topazkang/fe-dev:latest deploy: - runs-on: ubuntu-latest + runs-on: [ self-hosted, Linux, X64, connectrip_fe ] + name: Deploy on Self-Hosted Runner needs: build steps: - - name: SSH and Deploy Frontend - uses: appleboy/ssh-action@v0.1.8 - with: - host: ${{ secrets.EC2_HOST_DEV }} - username: ${{ secrets.EC2_USER }} - key: ${{ secrets.ARK_DEPLOY }} - port: 22 - script: | - echo "${{ secrets.ENV_FILE_DEV }}" > deploy/front/.env - echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u ${{ secrets.GIT_USER }} --password-stdin - cd deploy/front - sudo docker image prune -a -f - sudo docker-compose -f docker-compose.front.yaml down - sudo docker-compose -f docker-compose.front.yaml pull - sudo docker-compose -f docker-compose.front.yaml up -d + - name: set env & deploy + run: | + cd /home/ubuntu/deploy/front + echo "${{ secrets.ENV_FILE_DEV }}" > .env + echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u ${{ secrets.GIT_USER }} --password-stdin + sudo docker image prune -a -f + sudo docker-compose -f docker-compose.front.yaml down + sudo docker-compose -f docker-compose.front.yaml pull + sudo docker-compose -f docker-compose.front.yaml up -d diff --git a/.github/workflows/github-actions-prod.yaml b/.github/workflows/github-actions-prod.yaml index fe96bd0..104dd4e 100644 --- a/.github/workflows/github-actions-prod.yaml +++ b/.github/workflows/github-actions-prod.yaml @@ -29,8 +29,8 @@ jobs: NEXT_PUBLIC_SERVER_URL: ${{ secrets.NEXT_PUBLIC_SERVER_URL_PROD }} NEXT_PUBLIC_SELF_URL: ${{ secrets.NEXT_PUBLIC_SELF_URL_PROD }} NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL_PROD }} - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN_PROD }} + NEXT_PUBLIC_SENTRY_DSN: ${{ secrets.NEXT_PUBLIC_SENTRY_DSN_PROD }} - name: Log in to GitHub Container Registry uses: docker/login-action@v3 @@ -47,8 +47,8 @@ jobs: --build-arg NEXT_PUBLIC_SERVER_URL=${{ secrets.NEXT_PUBLIC_SERVER_URL_PROD }} \ --build-arg NEXT_PUBLIC_SELF_URL=${{ secrets.NEXT_PUBLIC_SELF_URL_PROD }} \ --build-arg NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL_PROD }} \ - --build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \ - --build-arg NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN }} \ + --build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN_PROD }} \ + --build-arg NEXT_PUBLIC_SENTRY_DSN=${{ secrets.NEXT_PUBLIC_SENTRY_DSN_PROD }} \ -t ghcr.io/topazkang/fe-prod:latest . - name: Push Docker image to GHCR diff --git a/dockerfile b/dockerfile index efc54d9..5094ce4 100644 --- a/dockerfile +++ b/dockerfile @@ -12,6 +12,7 @@ ARG NEXT_PUBLIC_SELF_URL ARG NEXT_PUBLIC_BASE_URL ARG SENTRY_AUTH_TOKEN ARG NEXT_PUBLIC_SENTRY_DSN +ARG NEXT_PUBLIC_KAKAOJSKEY # set env on variable ENV KAKAO_API_KEY=${KAKAO_API_KEY} @@ -21,6 +22,7 @@ ENV NEXT_PUBLIC_SELF_URL=${NEXT_PUBLIC_SELF_URL} ENV NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL} ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} ENV NEXT_PUBLIC_SENTRY_DSN=${NEXT_PUBLIC_SENTRY_DSN} +ENV NEXT_PUBLIC_KAKAOJSKEY=${NEXT_PUBLIC_KAKAOJSKEY} # Copy the package.json and package-lock.json COPY package*.json ./