Skip to content

Commit

Permalink
Merge pull request #63 from 100-hours-a-week/feature/deploy
Browse files Browse the repository at this point in the history
๐Ÿ‘ท github-actions ํ™˜๊ฒฝ์— ๋”ฐ๋ฅธ sentry ๋ถ„๋ฆฌ๋ฅผ ์œ„ํ•œ secret ๋ณ€์ˆ˜ ์ˆ˜์ •
  • Loading branch information
Namgyu11 authored Sep 2, 2024
2 parents 70e0787 + d737dbb commit 6450d3e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
37 changes: 17 additions & 20 deletions .github/workflows/github-actions-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/github-actions-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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 ./
Expand Down

0 comments on commit 6450d3e

Please sign in to comment.