From 0a270a90efb7bcd1eac9def9932455bd4d1b2169 Mon Sep 17 00:00:00 2001 From: TopazKang Date: Fri, 30 Aug 2024 08:10:05 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=91=B7=20github-actions=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EC=97=90=20=EB=94=B0=EB=A5=B8=20sentry=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=EB=A5=BC=20=EC=9C=84=ED=95=9C=20secret=20=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-dev.yaml | 8 ++++---- .github/workflows/github-actions-prod.yaml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/github-actions-dev.yaml b/.github/workflows/github-actions-dev.yaml index ee13ecf..466b62c 100644 --- a/.github/workflows/github-actions-dev.yaml +++ b/.github/workflows/github-actions-dev.yaml @@ -33,8 +33,8 @@ 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 }} - name: Log in to GitHub Container Registry uses: docker/login-action@v3 @@ -51,8 +51,8 @@ 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 }} \ -t ghcr.io/topazkang/fe-dev:latest . - name: Push Docker image to GHCR 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 From c671d2e17e40ebe77c9f4a76a6a54eac062dc0ce Mon Sep 17 00:00:00 2001 From: TopazKang Date: Mon, 2 Sep 2024 15:59:04 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=91=B7=20github-actions=20self-hosted?= =?UTF-8?q?=20Runner=20=EC=97=B0=EA=B2=B0=20=EB=B0=8F=20=EC=B9=B4=EC=B9=B4?= =?UTF-8?q?=EC=98=A4=20=EB=A7=B5=20api=20=EC=97=B0=EB=8F=99=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=ED=99=98=EA=B2=BD=20=EB=B3=80=EC=88=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(DEV=20=ED=99=98=EA=B2=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-dev.yaml | 33 ++++++++++++----------- dockerfile | 2 ++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/github-actions-dev.yaml b/.github/workflows/github-actions-dev.yaml index 466b62c..f958ec3 100644 --- a/.github/workflows/github-actions-dev.yaml +++ b/.github/workflows/github-actions-dev.yaml @@ -35,6 +35,7 @@ jobs: NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL_DEV }} 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 @@ -53,28 +54,28 @@ jobs: --build-arg NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL_DEV }} \ --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 ] + name: Deploy on Self-Hosted Runner needs: build + labels: + - connectrip_fe 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: Recreate .env file & login GHCR + run: | + echo "${{ secrets.ENV_FILE_DEV }}" > front/.env + echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u ${{ secrets.GIT_USER }} --password-stdin + + - name: Prune Docker Images and Deploy With Docker-Compose + run: | + sudo docker image prune -a -f + sudo docker-compose -f front/docker-compose.front.yaml down + sudo docker-compose -f front/docker-compose.front.yaml pull + sudo docker-compose -f front/docker-compose.front.yaml up -d 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 ./ From 586bdc1534a9144ce653db169372f0a7412160be Mon Sep 17 00:00:00 2001 From: TopazKang Date: Mon, 2 Sep 2024 16:10:56 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=91=B7=20github-actions=20self-hosted?= =?UTF-8?q?=20runner=20=20labels=20hot-fix#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-dev.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/github-actions-dev.yaml b/.github/workflows/github-actions-dev.yaml index f958ec3..198e416 100644 --- a/.github/workflows/github-actions-dev.yaml +++ b/.github/workflows/github-actions-dev.yaml @@ -61,11 +61,9 @@ jobs: run: docker push ghcr.io/topazkang/fe-dev:latest deploy: - runs-on: [ self-hosted, Linux, X64 ] + runs-on: [ self-hosted, Linux, X64, connectrip_fe ] name: Deploy on Self-Hosted Runner needs: build - labels: - - connectrip_fe steps: - name: Recreate .env file & login GHCR From be9d5bc77bd27c80b0c9eaafc0445277741a914e Mon Sep 17 00:00:00 2001 From: TopazKang Date: Mon, 2 Sep 2024 16:17:37 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=91=B7=20githb-actions=20self-hosted?= =?UTF-8?q?=20runner=20hot-fix#2=20no=20such=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-dev.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-actions-dev.yaml b/.github/workflows/github-actions-dev.yaml index 198e416..398b0ab 100644 --- a/.github/workflows/github-actions-dev.yaml +++ b/.github/workflows/github-actions-dev.yaml @@ -68,6 +68,7 @@ jobs: steps: - name: Recreate .env file & login GHCR run: | + pwd echo "${{ secrets.ENV_FILE_DEV }}" > front/.env echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u ${{ secrets.GIT_USER }} --password-stdin From 23d935b8d38613020ee0bda9f45a3e5fa928d8f4 Mon Sep 17 00:00:00 2001 From: TopazKang Date: Mon, 2 Sep 2024 16:31:17 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=91=B7=20github-actions=20self-hosted?= =?UTF-8?q?=20runner=20hot-fix#3=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-dev.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-dev.yaml b/.github/workflows/github-actions-dev.yaml index 398b0ab..8448a95 100644 --- a/.github/workflows/github-actions-dev.yaml +++ b/.github/workflows/github-actions-dev.yaml @@ -69,12 +69,12 @@ jobs: - name: Recreate .env file & login GHCR run: | pwd - echo "${{ secrets.ENV_FILE_DEV }}" > front/.env + echo "${{ secrets.ENV_FILE_DEV }}" > .env echo "${{ secrets.GHCR_TOKEN }}" | sudo docker login ghcr.io -u ${{ secrets.GIT_USER }} --password-stdin - name: Prune Docker Images and Deploy With Docker-Compose run: | sudo docker image prune -a -f - sudo docker-compose -f front/docker-compose.front.yaml down - sudo docker-compose -f front/docker-compose.front.yaml pull - sudo docker-compose -f front/docker-compose.front.yaml up -d + 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 From d737dbb6e6a2ee13ab36ab0b0755c85f29b9f8b3 Mon Sep 17 00:00:00 2001 From: TopazKang Date: Mon, 2 Sep 2024 16:41:38 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=91=B7=20github-actions=20self-hosted?= =?UTF-8?q?=20runner=20hot-fix#5=20directory=20path=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-dev.yaml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-dev.yaml b/.github/workflows/github-actions-dev.yaml index 8448a95..b7933a3 100644 --- a/.github/workflows/github-actions-dev.yaml +++ b/.github/workflows/github-actions-dev.yaml @@ -66,14 +66,11 @@ jobs: needs: build steps: - - name: Recreate .env file & login GHCR + - name: set env & deploy run: | - pwd + 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 - - - name: Prune Docker Images and Deploy With Docker-Compose - run: | sudo docker image prune -a -f sudo docker-compose -f docker-compose.front.yaml down sudo docker-compose -f docker-compose.front.yaml pull