Skip to content

👷 github-actions self-hosted runner hot-fix#3 directory #66

👷 github-actions self-hosted runner hot-fix#3 directory

👷 github-actions self-hosted runner hot-fix#3 directory #66

name: Front-dev build & push docker image to ghcr and deploy
on:
push:
branches:
- dev
- feature/deploy
pull_request:
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Build Next.js app
run: npm run build
env:
KAKAO_API_KEY: ${{ secrets.KAKAO_API_KEY_DEV }}
KAKAO_REDIRECT_URI: ${{ secrets.KAKAO_REDIRECT_URI_DEV }}
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_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
with:
registry: ghcr.io
username: TopazKang
password: ${{ secrets.GHCR_TOKEN }}
- name: Build Docker image
run: |
docker build \
--build-arg KAKAO_API_KEY=${{ secrets.KAKAO_API_KEY_DEV }} \
--build-arg KAKAO_REDIRECT_URI=${{ secrets.KAKAO_REDIRECT_URI_DEV }} \
--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_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: [ self-hosted, Linux, X64, connectrip_fe ]
name: Deploy on Self-Hosted Runner
needs: build
steps:
- name: Recreate .env file & login GHCR
run: |
pwd
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
sudo docker-compose -f docker-compose.front.yaml up -d